list.html 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901
  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. <style>
  11. .layui-btn-container {
  12. display: flex; /* 启用弹性盒布局 */
  13. flex-wrap: wrap; /* 如果需要,允许换行 */
  14. gap: 3px; /* 可选:为按钮之间添加间距 */
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. <div class="layuimini-container">
  20. <div class="layuimini-main">
  21. <fieldset class="table-search-fieldset">
  22. <legend>搜索信息(<b>收起-展开</b>)</legend>
  23. <div id="search-div" style="margin: 5px 10px -10px 0px">
  24. <form class="layui-form" action="" lay-filter="search-form">
  25. <div class="layui-form-item">
  26. <div class="layui-inline">
  27. <label class="layui-form-label" style="width: 60px">中文名称</label>
  28. <div class="layui-input-inline" style="width: 150px">
  29. <input type="text" name="zwmc" id="zwmc" autocomplete="off" class="layui-input">
  30. </div>
  31. </div>
  32. <div class="layui-inline">
  33. <label class="layui-form-label" style="width: 60px">ERP编号</label>
  34. <div class="layui-input-inline" style="width: 150px">
  35. <input type="text" name="erpbh" id="erpbh" autocomplete="off" class="layui-input">
  36. </div>
  37. </div>
  38. <div class="layui-inline">
  39. <label class="layui-form-label" style="width: 60px">项目类型</label>
  40. <div class="layui-input-inline" style="width: 150px">
  41. <select name="xmlx" id="xmlx" lay-filter="status">
  42. <option value="">全部</option>
  43. <option th:each="item:${xmlxList}" th:text="${item.name}"
  44. th:value="${item.code}"></option>
  45. </select>
  46. </div>
  47. </div>
  48. <div class="layui-inline">
  49. <label class="layui-form-label" style="width: 60px">审批状态</label>
  50. <div class="layui-input-inline" style="width: 150px">
  51. <select name="spzt" lay-filter="status">
  52. <option value="">全部</option>
  53. <!--<option th:each="item:${dictList}" th:text="${item.name}"
  54. th:value="${item.name}"></option>-->
  55. <option value="未提交">未提交</option>
  56. <option value="未提交(返回)">未提交(返回)</option>
  57. <option value="科研计划专责审批">科研计划专责审批</option>
  58. <option value="审批结束">审批结束</option>
  59. </select>
  60. </div>
  61. </div>
  62. <br>
  63. <div class="layui-inline">
  64. <label class="layui-form-label" style="width: 60px">是否修改</label>
  65. <div class="layui-input-inline" style="width: 150px">
  66. <select name="sfxg" id="sfxg" lay-filter="status">
  67. <option value="">全部</option>
  68. <option value='0'>未修改</option>
  69. <option value='1'>已修改</option>
  70. </select>
  71. </div>
  72. </div>
  73. <div class="layui-inline" style="margin-left: 0px">
  74. <button type="submit" class="layui-btn" lay-submit lay-filter="data-search-btn"><i
  75. class="layui-icon"></i> 搜 索
  76. </button>
  77. <button type="submit" class="layui-btn layui-btn-primary" lay-submit
  78. lay-filter="data-reset-btn"><i class="layui-icon layui-icon-refresh"></i> 重 置
  79. </button>
  80. </div>
  81. </div>
  82. </form>
  83. </div>
  84. </fieldset>
  85. <script type="text/html" id="toolbarDemo">
  86. <div class="layui-btn-container">
  87. <!-- <button class="layui-btn layui-btn-sm data-add-btn" lay-event="add">
  88. <i class="layui-icon layui-icon-addition" style="font-size: 10px;"></i>新增
  89. </button>-->
  90. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="edit">
  91. <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>编辑
  92. </button>
  93. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="view">
  94. <i class="layui-icon layui-icon-file" style="font-size: 10px;"></i>查看
  95. </button>
  96. <!-- <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delete">
  97. <i class="layui-icon layui-icon-delete" style="font-size: 10px;"></i>删除
  98. </button>-->
  99. <!-- <button class="layui-btn layui-btn-sm data-add-btn" lay-event="tjApprove">
  100. <i class="layui-icon layui-icon-ok" style="font-size: 10px;"></i>提交审批
  101. </button>-->
  102. <button class="layui-btn layui-btn-sm data-add-btn" lay-event="tjrevokeApprove">
  103. <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>撤销审批
  104. </button>
  105. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="spOption">
  106. <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>审核
  107. </button>
  108. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="spList">
  109. <i class="layui-icon layui-icon-list" style="font-size: 10px;"></i>审批列表
  110. </button>
  111. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="xgjl">
  112. <i class="layui-icon layui-icon-file" style="font-size: 10px;"></i>修改记录
  113. </button>
  114. <button class="layui-btn layui-btn-sm" lay-event="downloadWord">
  115. <i class="layui-icon layui-icon-export" style="font-size: 10px;"></i>导出单个项目
  116. </button>
  117. <!-- <button class="layui-btn layui-btn-sm" lay-event="exportExcel">-->
  118. <!-- <i class="layui-icon layui-icon-export" style="font-size: 10px;"></i>导出列表-->
  119. <!-- </button>-->
  120. <button class="layui-btn layui-btn-sm" lay-event="exportExcel" style="background-color: black">
  121. <i class="layui-icon layui-icon-export" style="font-size: 10px;"></i>导出列表
  122. </button>
  123. <button class="layui-btn layui-btn-sm" lay-event="backSpacing" style="background: #FF8040"
  124. id="myButton">
  125. <i class="layui-icon layui-icon-return" style="font-size: 10px;"></i>审批回退
  126. </button>
  127. <button class="layui-btn layui-btn-sm" lay-event="tongBu" style="background: #FF8040"
  128. id="tbPrjAnnuaalbudget">
  129. 同步年度预算
  130. </button>
  131. <!-- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="Xgsq">-->
  132. <!-- <i class="layui-icon layui-icon-file" style="font-size: 10px;"></i>修改申请-->
  133. <!-- </button>-->
  134. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="viewXgsq">
  135. <i class="layui-icon layui-icon-file" style="font-size: 10px;"></i>查看修改申请
  136. </button>
  137. <button class="layui-btn layui-btn-sm layui-btn-checked" lay-event="xmzy" id="zy" style="display: none">
  138. <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>项目转移
  139. </button>
  140. </div>
  141. </script>
  142. <input type="hidden" id="userId" name="userId" class="layui-input" th:value="${userId}">
  143. <input type="hidden" id="postId" name="postId" class="layui-input" th:value="${postId}">
  144. <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
  145. <!-- <script type="text/html" id="currentTableBar">-->
  146. <!-- <a class="layui-btn layui-btn-xs layui-btn-warm data-count-view" lay-event="view">-->
  147. <!-- <i class="layui-icon layui-icon-set" style="font-size: 10px;"></i>查看-->
  148. <!-- </a>-->
  149. <!-- <a class="layui-btn layui-btn-xs data-count-update" lay-event="update">-->
  150. <!-- <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>编辑-->
  151. <!-- </a>-->
  152. <!-- <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delFlag">-->
  153. <!-- <i class="layui-icon layui-icon-delete" style="font-size: 10px;"></i>删除-->
  154. <!-- </a>-->
  155. <!-- </script>-->
  156. </div>
  157. </div>
  158. <script>
  159. // 获取所有需要去除空格的输入框
  160. const inputs = [
  161. document.getElementById('zwmc'),
  162. document.getElementById('erpbh')
  163. ];
  164. // 为每个输入框添加事件监听
  165. inputs.forEach(input => {
  166. input.addEventListener('input', function() {
  167. this.value = this.value.replace(/\s+/g, ''); // 去除空格
  168. });
  169. });
  170. </script>
  171. <script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
  172. <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
  173. <script th:src="@{/lib/coco-message/coco-message.js}" charset="utf-8"></script>
  174. <script th:src="@{/js/lay-config.js}" charset="utf-8"></script>
  175. <script th:src="@{/lib/xm-select-v1.2.2/xm-select.js}" charset="utf-8"></script>
  176. <script th:inline="javascript" type="text/javascript">
  177. AjaxUtil.ctx = /*[[@{/}]]*/'';
  178. var updateflag = 0;
  179. var xmApproval = {};
  180. layui.use(['form', 'table'], function () {
  181. var form = layui.form,
  182. table = layui.table,
  183. layer = layui.layer;
  184. var userId = $("#userId").val();
  185. var postId = $("#postId").val();
  186. var currTable = table.render({
  187. elem: '#currentTableId',
  188. url: AjaxUtil.ctx + 'prjProject/list',
  189. method: 'post',
  190. toolbar: '#toolbarDemo',
  191. defaultToolbar: ['filter', 'exports', 'print'],
  192. cols: [
  193. [
  194. {type: "checkbox", fixed: 'left'},
  195. {type: 'numbers', align: 'center',title: '😊'},
  196. {field: 'zwmc', width: '26%', title: '中文名称'},
  197. {field: 'spzt', width: '10%', title: '审批状态', sort: true},
  198. {field: 'erpbh', width: '10%', title: 'ERP编号'},
  199. {field: 'jf',width: '7%' ,title: '子课题经费(元)' ,align: 'right'},
  200. {field: 'czze', width: '7%',title: '出资总额(元)', align: 'right'},
  201. {field: 'sqze',width: '7%',title: '申请总额(元)',align: 'right'},
  202. {field: 'bzze', width: '7%', title: '报账总额(元)',align: 'right'},
  203. {field: 'yfze',width: '7%',title: '已付总额(元)',align: 'right'},
  204. {field: 'xmlxmc', width: '15%', title: '项目类型'},
  205. {field: 'qs', width: '8%', title: '起始', align: 'center'},
  206. {field: 'wc', width: '8%', title: '完成', align: 'center'},
  207. {field: 'cjrxm', width: '7%', title: '创建人', align: 'center'},
  208. {field: 'cjrq', width: '8%', title: '创建时间', align: 'center'}
  209. // {title: '操作', toolbar: '#currentTableBar', align: 'center', fixed: 'right'}
  210. ]
  211. ],
  212. autoSort: false,
  213. limits: [10, 15, 20, 25, 50, 100],
  214. limit: 10,
  215. page: true,
  216. skin: 'grid',
  217. parseData: function (res) { //res 即为原始返回的数据
  218. return {
  219. "code": res.code, //解析接口状态
  220. "msg": res.message, //解析提示文本
  221. "count": res.data.total, //解析数据长度
  222. "data": res.data.rows //解析数据列表
  223. };
  224. },
  225. done: function (res, curr, count) { // done为数据渲染完的回调
  226. // 测试打印出后端返回的权限列表
  227. // let permissionSet = [[${permissionSet}]];
  228. // console.log(JSON.stringify(permissionSet));
  229. if (postId != 19 && postId != 39 && userId != 1) {
  230. document.getElementById("myButton").style.display = 'none';
  231. }
  232. if (postId != 19 && postId != 39 && userId != 1) {
  233. document.getElementById("tbPrjAnnuaalbudget").style.display = 'none';
  234. }
  235. }
  236. });
  237. // 监听搜索操作
  238. form.on('submit(data-search-btn)', function (data) {
  239. // 执行搜索重载
  240. currTable.reload({
  241. page: {
  242. curr: 1 // 页码从1开始
  243. },
  244. where: form.val("search-form")
  245. });
  246. // 刷新按钮
  247. var userId = $("#userId").val();
  248. console.log("搜索"+userId);
  249. if (userId == 1 || userId == 42){
  250. document.getElementById('zy').style.display = 'block'
  251. layer.msg('加载完成',{icon:1});
  252. }
  253. return false;
  254. });
  255. // 监听重置操作
  256. form.on('submit(data-reset-btn)', function (data) {
  257. form.val("search-form", {
  258. "zwmc": '',
  259. "erpbh": '',
  260. "xmlx": '',
  261. "spzt": '',
  262. "sfxg": ''
  263. });
  264. // 执行搜索重载
  265. currTable.reload({
  266. page: {
  267. curr: 1
  268. },
  269. where: form.val("search-form")
  270. });
  271. return false;
  272. });
  273. // 监听排序事件
  274. table.on('sort(currentTableFilter)', function (obj) { //注:sort 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值"
  275. // console.log(obj.field); //当前排序的字段名
  276. // console.log(obj.type); //当前排序类型:desc(降序)、asc(升序)、null(空对象,默认排序)
  277. // console.log(this); //当前排序的 th 对象
  278. //尽管我们的 table 自带排序功能,但并没有请求服务端。
  279. //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如:
  280. currTable.reload({
  281. initSort: obj, //记录初始排序,如果不设的话,将无法标记表头的排序状态。
  282. where: { //请求参数(注意:这里面的参数可任意定义,并非下面固定的格式)
  283. sortName: toLine(obj.field), //排序字段
  284. sortOrder: toLine(obj.type) //排序方式
  285. }
  286. });
  287. });
  288. // 监听行工具事件
  289. table.on('toolbar(currentTableFilter)', function (obj) {
  290. if (obj.event === 'add') { // 监听添加操作
  291. layer.open({
  292. title: '新建项目任务书',
  293. type: 2,
  294. shade: 0.3,
  295. maxmin: true,
  296. area: ['1090px', layerheight + 'px'],
  297. content: AjaxUtil.ctx + 'prjProject/forAdd',
  298. end: function (index) {
  299. // 重载表格
  300. if (updateflag == 1)
  301. currTable.reload();
  302. updateflag = 0;
  303. }
  304. });
  305. // layer.full(index);
  306. } else if (obj.event == 'edit') {
  307. var projects = table.cache["currentTableId"];
  308. if (projects.length == 0)
  309. return;
  310. var checkStatus = table.checkStatus('currentTableId')
  311. , data = checkStatus.data;
  312. if (data == null || data.length === 0) {
  313. Message.warning("请选择要编辑的任务书!", 1500);
  314. } else if (data.length > 1) {
  315. Message.warning("请选择一条记录进行编辑操作!", 1500);
  316. } else {
  317. console.log("修改项目任务书");
  318. layer.open({
  319. title: '修改项目任务书',
  320. type: 2,
  321. shade: 0.3,
  322. maxmin: true,
  323. shadeClose: true,
  324. area: ['1090px', layerheight + 'px'],
  325. content: AjaxUtil.ctx + 'prjProject/forUpdate/' + data[0].id,
  326. success: function (layero, index) {
  327. },
  328. end: function (index) {
  329. if (updateflag == 1)
  330. currTable.reload();
  331. updateflag = 0;
  332. }
  333. });
  334. // layer.full(index);
  335. }
  336. } else if (obj.event == 'Xgsq') {
  337. var projects = table.cache["currentTableId"];
  338. if (projects.length == 0)
  339. return;
  340. var checkStatus = table.checkStatus('currentTableId')
  341. , data = checkStatus.data;
  342. if (data == null || data.length === 0) {
  343. Message.warning("请选择要编辑的任务书!", 1500);
  344. } else if (data.length > 1) {
  345. Message.warning("请选择一条记录进行编辑操作!", 1500);
  346. }else if(data[0].spzt != '审批结束'){
  347. Message.warning("该功能需在审批结束后使用!", 1500);
  348. } else {
  349. console.log("修改项目任务书");
  350. layer.open({
  351. title: '修改项目任务书',
  352. type: 2,
  353. shade: 0.3,
  354. maxmin: true,
  355. shadeClose: true,
  356. area: ['1090px', layerheight + 'px'],
  357. content: AjaxUtil.ctx + 'prjProject/forXgUpdate/' + data[0].id,
  358. success: function (layero, index) {
  359. },
  360. end: function (index) {
  361. if (updateflag == 1)
  362. currTable.reload();
  363. updateflag = 0;
  364. }
  365. });
  366. // layer.full(index);
  367. }
  368. } else if (obj.event == 'view') {
  369. var projects = table.cache["currentTableId"];
  370. if (projects.length == 0)
  371. return;
  372. var checkStatus = table.checkStatus('currentTableId')
  373. , data = checkStatus.data;
  374. if (data == null || data.length === 0) {
  375. Message.warning("请选择要查看的任务书!", 1500);
  376. } else if (data.length > 1) {
  377. Message.warning("请选择一条记录进行查看!", 1500);
  378. } else {
  379. layer.open({
  380. title: '查看项目任务书',
  381. type: 2,
  382. shade: 0.3,
  383. maxmin: true,
  384. shadeClose: true,
  385. area: ['1090px', layerheight + 'px'],
  386. content: AjaxUtil.ctx + 'prjProject/forView/' + data[0].id,
  387. end: function (index) {
  388. layer.close(index);
  389. }
  390. });
  391. // layer.full(index);
  392. }
  393. } else if (obj.event === 'delete') { // 监听删除操作
  394. var projects = table.cache["currentTableId"];
  395. if (projects.length == 0)
  396. return;
  397. var checkStatus = table.checkStatus('currentTableId')
  398. , data = checkStatus.data;
  399. if (data == null || data.length === 0) {
  400. Message.warning("请选择要删除的任务书!", 1000);
  401. return;
  402. } else {
  403. for (let item of data) {
  404. if (item.cjr != userId) {
  405. Message.error("存在您不是创建人的任务书,不能直接删除!", 2000);
  406. return;
  407. }
  408. if (item.spzt != "未提交") {
  409. if (item.spzt == "审批结束")
  410. Message.warning("存在已审批结束的可研报告,不能直接删除!", 2000);
  411. else if (data[0].spzt != null)
  412. Message.warning("存在审批中的可研报告,不能直接删除!", 2000);
  413. return;
  414. }
  415. }
  416. }
  417. layer.confirm('确定批量删除项目任务书吗?', function (index) {
  418. layer.close(index);
  419. AjaxUtil.post({
  420. url: AjaxUtil.ctx + "prjProject/batchDelete",
  421. contentType: "application/json",
  422. data: JSON.stringify(data),
  423. success: function (res) {
  424. if (res.code === 0) {
  425. Message.success(1500, res.message, function () {
  426. // 重载表格
  427. currTable.reload();
  428. });
  429. } else {
  430. Message.error(res.message, 1000);
  431. }
  432. },
  433. error: function (error) {
  434. }
  435. });
  436. });
  437. } else if (obj.event === 'exportExcel') {
  438. var formData = form.val('search-form');
  439. // 获取form 表单代码
  440. console.log(formData);
  441. var formDataString = JSON.stringify(formData);
  442. /* var projects = table.cache["currentTableId"];
  443. if (projects.length == 0)
  444. return;
  445. let a = document.createElement('a');
  446. a.href = AjaxUtil.ctx + 'prjProject/exportExcel/' + formDataString;
  447. a.click();
  448. a.parentNode.removeChild(a);*/
  449. AjaxUtil.post({
  450. url:AjaxUtil.ctx +'prjProject/getAll/'+formDataString,
  451. contentType: "application/json",
  452. timeout: 15000, //大批量导出时会出现超时问题
  453. success: function(res){
  454. console.log(res);
  455. table.exportFile('currentTableId',res.data,'xlsx',{
  456. fileName: '任务书列表.xlsx'
  457. });
  458. },
  459. error:function (error) {
  460. Message.error(error,2000)
  461. }
  462. });
  463. } else if (obj.event === 'tjApprove') {
  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. } else if (data[0].spzt != null && data[0].spzt.indexOf("未提交") < 0) {
  476. Message.warning("该任务书正在审批中……", 1500);
  477. } else if (data[0].cjr != userId) {
  478. Message.error("您不是该任务书的创建人!", 1500);
  479. } else {
  480. xmApproval = {
  481. "xmid": data[0].id,
  482. "xm": data[0].zwmc,
  483. "zt": data[0].spzt
  484. };
  485. if (data[0].spzt == null) {
  486. xmApproval.zt = "未提交";
  487. data[0].spzt = "未提交";
  488. }
  489. var content = AjaxUtil.ctx + 'prjProject/forApproveAdd';
  490. if (data[0].spzt != "未提交")
  491. // content = AjaxUtil.ctx + 'prjProject/forApproveUpdate/' + data[0].id + '?spzt=' + data[0].spzt;
  492. content = AjaxUtil.ctx + 'prjProject/forApproveUpdate/' + data[0].id + '/' + data[0].ysje + '?spzt=' + data[0].spzt;
  493. layer.open({
  494. title: '提交审批',
  495. type: 2,
  496. shade: 0.3,
  497. maxmin: true,
  498. shadeClose: true,
  499. area: ['1025px', layerheight + 'px'],
  500. content: content,
  501. end: function (index) {
  502. if (updateflag == 1)
  503. currTable.reload();
  504. updateflag = 0;
  505. }
  506. });
  507. }
  508. } else if (obj.event === 'spOption') {
  509. var projects = table.cache["currentTableId"];
  510. if (projects.length == 0)
  511. return;
  512. var checkStatus = table.checkStatus('currentTableId')
  513. , data = checkStatus.data;
  514. if (data == null || data.length === 0) {
  515. Message.warning("请选择要审批的任务书!", 1500);
  516. } else if (data.length > 1) {
  517. Message.warning("请选择一条记录进行审批!", 1500);
  518. } else if (data[0].spzt == null || data[0].spzt.indexOf("未提交") >= 0) {
  519. Message.warning("该任务书尚未提交审批!", 1500);
  520. } else if (data[0].spzt == "审批结束") {
  521. Message.warning("该任务书已审批结束!", 1500);
  522. } else {
  523. // 判断当前人员是否是审核人
  524. AjaxUtil.get({
  525. url: AjaxUtil.ctx + "prjAnnualbudget/getshr?xmid="+data[0].id+'&spzt='+data[0].spzt,
  526. contentType: "application/json",
  527. success: function (res) {
  528. if (res.code === -1) {
  529. layer.msg(res.message,{icon:2});
  530. return;
  531. } else if (res.code === -2){
  532. layer.msg(res.message,{icon:2});
  533. return;
  534. }else {
  535. xmApproval = {
  536. "xmid": data[0].id,
  537. "xm": data[0].zwmc,
  538. "ysje": data[0].ysje
  539. };
  540. layer.open({
  541. title: '审批意见',
  542. type: 2,
  543. shade: 0.3,
  544. maxmin: true,
  545. shadeClose: true,
  546. area: ['1025px', layerheight + 'px'],
  547. content: AjaxUtil.ctx + 'prjProject/forApproveUpdate/' + data[0].id + '/' + data[0].ysje + '?spzt=' + data[0].spzt,
  548. end: function (index) {
  549. if (updateflag == 1)
  550. currTable.reload();
  551. updateflag = 0;
  552. }
  553. });
  554. }
  555. },
  556. error: function (error) {
  557. }
  558. });
  559. }
  560. } else if (obj.event === 'spList') {
  561. var projects = table.cache["currentTableId"];
  562. if (projects.length == 0)
  563. return;
  564. var checkStatus = table.checkStatus('currentTableId')
  565. , data = checkStatus.data;
  566. if (data == null || data.length === 0) {
  567. Message.warning("请选择要查看审批列表的任务书!", 1500);
  568. } else if (data.length > 1) {
  569. Message.warning("请选择一条记录进行查看!", 1500);
  570. } else if (data[0].spzt == null || data[0].spzt == "未提交") {
  571. Message.warning("该任务书尚未提交审批!", 1500);
  572. } else {
  573. xmApproval = {
  574. "xmid": data[0].id,
  575. "xm": data[0].zwmc
  576. };
  577. var index = layer.open({
  578. title: '审批列表',
  579. type: 2,
  580. shade: 0.3,
  581. maxmin: true,
  582. shadeClose: true,
  583. area: ['1300px', layerheight + 'px'],
  584. content: AjaxUtil.ctx + 'prjProject/forApproveList',
  585. end: function () {
  586. layer.close(index);
  587. }
  588. });
  589. }
  590. } else if (obj.event == 'backSpacing') {
  591. var project = table.cache["currentTableId"];
  592. if (project.length == 0) {
  593. return;
  594. }
  595. var checkStatus = table.checkStatus('currentTableId')
  596. , data = checkStatus.data;
  597. if (data == null || data.length === 0) {
  598. Message.warning("请选择要回退的任务书!", 1500);
  599. } else if (data.length > 1) {
  600. Message.warning("请选择一条记录进行回退!", 1500);
  601. } else if (data[0].spzt != "审批结束") {
  602. Message.warning("该任务书未审批结束,不能回退!", 1500);
  603. } else {
  604. layer.confirm('确定要将任务书回退至未提交状态吗?', function (index) {
  605. layer.close(index);
  606. AjaxUtil.post({
  607. url: AjaxUtil.ctx + "prjProject/upDataSpzt/" + userId,
  608. contentType: "application/json",
  609. data: JSON.stringify(data),
  610. success: function (res) {
  611. if (res.code === 0) {
  612. Message.success(1500, res.message, function () {
  613. // 重载表格
  614. currTable.reload();
  615. });
  616. } else {
  617. Message.error(res.message, 1000);
  618. }
  619. },
  620. error: function (error) {
  621. }
  622. });
  623. });
  624. }
  625. }else if (obj.event === 'xgjl') {
  626. var dataBudget = table.cache["currentTableId"];
  627. if (dataBudget.length == 0)
  628. return;
  629. var checkStatus = table.checkStatus('currentTableId')
  630. , data = checkStatus.data;
  631. if (data == null || data.length === 0) {
  632. Message.warning("请选择要查看修改记录的任务书!", 1500);
  633. } else if (data.length > 1) {
  634. Message.warning("请选择一条记录进行查看!", 1500);
  635. } else if (data[0].spzt == null || data[0].spzt != "审批结束") {
  636. Message.warning("该任务书还未审批结束!", 1500);
  637. } else {
  638. xmApproval = {
  639. "xmid": data[0].id,
  640. "xm": data[0].zwmc
  641. };
  642. var index = layer.open({
  643. title: '修改记录',
  644. type: 2,
  645. shade: 0.3,
  646. maxmin: true,
  647. shadeClose: true,
  648. area: ['1300px', layerheight + 'px'],
  649. content: AjaxUtil.ctx + 'prjProject/viewRecord',
  650. end: function () {
  651. layer.close(index);
  652. }
  653. });
  654. }
  655. } else if (obj.event === 'downloadWord') { // 监听查看操作
  656. var projects = table.cache["currentTableId"];
  657. if (projects.length == 0)
  658. return;
  659. var checkStatus = table.checkStatus('currentTableId')
  660. , data = checkStatus.data;
  661. if (data == null || data.length === 0) {
  662. Message.warning("请选择要导出的任务书!", 1500);
  663. } else if (data.length > 1) {
  664. Message.warning("请选择一条记录进行导出!", 1500)
  665. } else {
  666. layer.confirm('是否确定导出任务书——' + data[0].zwmc + '?', {
  667. btn: ['导出', '取消']
  668. }, function (index, layero) {
  669. window.location.href = AjaxUtil.ctx + "prjProject/exportWord/" + data[0].id;
  670. layer.close(index);
  671. }, function (index) {
  672. });
  673. }
  674. } else if (obj.event === 'tjrevokeApprove') {
  675. var projects = table.cache["currentTableId"];
  676. if (projects.length == 0)
  677. return;
  678. var checkStatus = table.checkStatus('currentTableId')
  679. , data = checkStatus.data;
  680. if (data == null || data.length === 0) {
  681. Message.warning("请选择要撤销的任务书!", 1500);
  682. } else if (data.length > 1) {
  683. Message.warning("请选择一条记录进行撤销!", 1500);
  684. } else if (data[0].spzt == "审批结束") {
  685. Message.warning("该任务书已审批结束!", 1500);
  686. }
  687. //else if (data[0].cjr != userId) {
  688. // Message.error("您不是该任务书的创建人!", 1500);}
  689. else {
  690. xmApproval = {
  691. "xmid": data[0].id,
  692. "xm": data[0].zwmc,
  693. "zt": "未提交"
  694. };
  695. if (data[0].spzt == null) {
  696. xmApproval.zt = "未提交";
  697. data[0].spzt = "未提交";
  698. }
  699. var project = {
  700. "id": xmApproval.xmid,
  701. "spzt": '未提交'
  702. }
  703. layer.confirm('确定撤销项目任务书吗?', function (index) {
  704. layer.close(index);
  705. AjaxUtil.post({
  706. url: AjaxUtil.ctx + "prjProject/TJrevokeApprove",
  707. contentType: "application/json",
  708. data: JSON.stringify(project),
  709. success: function (res) {
  710. if (res.code === 0) {
  711. Message.success(1500, res.message, function () {
  712. // 重载表格
  713. currTable.reload();
  714. });
  715. } else {
  716. Message.error(res.message, 1000);
  717. }
  718. },
  719. error: function (error) {
  720. }
  721. });
  722. });
  723. }
  724. }else if (obj.event==='tongBu'){
  725. var project = table.cache["currentTableId"];
  726. if (project.length == 0) {
  727. return;
  728. }
  729. var checkStatus = table.checkStatus('currentTableId')
  730. , data = checkStatus.data;
  731. if (data == null || data.length === 0) {
  732. Message.warning("请选择要同步数据的任务书!", 1500);
  733. } else if (data.length > 1) {
  734. Message.warning("请选择一条记录进行同步!", 1500);
  735. } else if (data[0].spzt != "审批结束") {
  736. Message.warning("该任务书未审批结束,不能同步!", 1500);
  737. } else {
  738. layer.confirm('确定要将该任务书进行数据同步吗?', function (index) {
  739. layer.close(index);
  740. AjaxUtil.get({
  741. url: AjaxUtil.ctx + "updatePrj_AnnualBudgetDetail/?rws="+data[0].id,
  742. contentType: "application/json",
  743. success: function (res) {
  744. if (res.code === 0) {
  745. Message.success(1500, res.message, function () {
  746. // 重载表格
  747. currTable.reload();
  748. });
  749. } else {
  750. Message.error(res.message, 1000);
  751. }
  752. },
  753. error: function (error) {
  754. }
  755. });
  756. });
  757. }
  758. }else if(obj.event === 'xmzy'){
  759. var project = table.cache['currentTableId'];// 绑定表格元素 cache 表示缓存的意思
  760. // 判断缓存是否为空
  761. if(project.length == 0){
  762. return;
  763. }
  764. // 获取table 中 缓存的数据
  765. var checkStatus = table.checkStatus('currentTableId')
  766. ,data = checkStatus.data;
  767. if (data == null || data.length === 0){
  768. layer.msg('请选择要转移的项目',{icon: 3});
  769. }else if (data.length > 1){
  770. layer.msg('请选择一条项目进项转移',{icon:3});
  771. }else if (data[0].spzt != '审批结束'){
  772. layer.msg('该任务书未审批结束,不能转移',{icon:3});
  773. }else {
  774. layer.open({
  775. title: '项目转移',
  776. type: 2,
  777. shade: 0.3,
  778. maxmin: true,
  779. shadeClose: true,
  780. area: ['1090px', layerheight + 'px'],
  781. content: AjaxUtil.ctx + 'prjProject/updateSsbm/' + data[0].id,
  782. success: function (layero, index) {
  783. },
  784. end: function (index) {
  785. // 刷新表格
  786. if (updateflag == 1)
  787. currTable.reload();
  788. updateflag = 0;
  789. }
  790. });
  791. }
  792. }else if (obj.event =="viewXgsq"){
  793. var index = layer.open({
  794. title: '修改申请',
  795. type: 2,
  796. shade: 0.3,
  797. maxmin: true,
  798. shadeClose: true,
  799. area: ['1300px', layerheight + 'px'],
  800. content: AjaxUtil.ctx+ "prjProject/ViewXGSQ",
  801. end: function () {
  802. layer.close(index);
  803. }
  804. });
  805. }
  806. });
  807. //双击
  808. table.on('rowDouble(currentTableFilter)', function (obj) {
  809. var data = obj.data;
  810. layer.open({
  811. title: '查看项目任务书',
  812. type: 2,
  813. shade: 0.3,
  814. maxmin: true,
  815. shadeClose: true,
  816. area: ['1090px', layerheight + 'px'],
  817. content: AjaxUtil.ctx + 'prjProject/forView/' + data.id,
  818. end: function (index) {
  819. layer.close(index);
  820. }
  821. });
  822. // layer.full(index);
  823. });
  824. });
  825. function setUpdateFlag() {
  826. updateflag = 1;
  827. }
  828. function getXmApproval() {
  829. return xmApproval;
  830. }
  831. $(document).ready(function (){
  832. setTimeout(function (){
  833. var userId = $("#userId").val();
  834. console.log(userId);
  835. if (userId == 1 || userId == 42){
  836. document.getElementById('zy').style.display = 'block'
  837. layer.msg('加载完成',{icon:1});
  838. }
  839. },1000);
  840. });
  841. </script>
  842. </body>
  843. </html>