list_approving.html 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  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: 200px">
  22. <input type="text" id="xmmc" name="xmmc" 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: 225px">
  28. <input type="text" id="erpbh" name="erpbh" autocomplete="off" class="layui-input">
  29. </div>
  30. </div>
  31. <div class="layui-inline">
  32. <label class="layui-form-label" style="width: 90px">科研费号</label>
  33. <div class="layui-input-inline" style="width: 150px">
  34. <input type="text" id="bh" name="bh" autocomplete="off" class="layui-input">
  35. </div>
  36. </div>
  37. <div class="layui-inline">
  38. <label class="layui-form-label" style="width: 30px">年份</label>
  39. <div class="layui-input-inline" style="width: 150px">
  40. <select name="nf" id="nf" lay-filter="status">
  41. <option value="0">全部</option>
  42. <option th:each="item:${yearList}" th:text="${item.nf}" th:value="${item.nf}"></option>
  43. </select>
  44. </div>
  45. </div>
  46. <div class="layui-inline">
  47. <label class="layui-form-label" style="width: 60px">审批状态</label>
  48. <div class="layui-input-inline" style="width: 200px">
  49. <select name="spzt" id="spzt" lay-filter="status">
  50. <option value="">全部</option>
  51. <option th:each="item:${approveList}" th:text="${item.name}" th:value="${item.name}"></option>
  52. </select>
  53. </div>
  54. </div>
  55. <div class="layui-inline">
  56. <label class="layui-form-label" style="width: 60px">项目类型</label>
  57. <div class="layui-input-inline" style="width: 200px">
  58. <select name="xmlx" id="xmlx" lay-filter="status">
  59. <option value="">全部</option>
  60. <option th:each="item:${xmlxList}" th:text="${item.name}" th:value="${item.code}"></option>
  61. </select>
  62. </div>
  63. </div>
  64. <!-- <div class="layui-inline">-->
  65. <!-- <label class="layui-form-label" style="width: 70px">是否备用金</label>-->
  66. <!-- <div class="layui-input-inline" style="width: 150px">-->
  67. <!-- <select name="sfbyj" id="sfbyj" lay-filter="status">-->
  68. <!-- <option value="">全部</option>-->
  69. <!-- <option value="1">是</option>-->
  70. <!-- <option value="0">否</option>-->
  71. <!-- </select>-->
  72. <!-- </div>-->
  73. <!-- </div>-->
  74. <!-- <br>-->
  75. <div class="layui-inline" style="left: -30px">
  76. <label class="layui-form-label" style="width: 90px">电科院负责人</label>
  77. <div class="layui-input-inline" style="width: 225px">
  78. <input type="hidden" id="dkyfzr" name="dkyfzr" class="layui-input">
  79. <input type="text" id="dkyfzrxm" name="dkyfzrxm" placeholder="可多选" class="layui-input" readonly>
  80. </div>
  81. </div>
  82. <br>
  83. <div class="layui-inline">
  84. <label class="layui-form-label" style="width: 60px;">所属部门</label>
  85. <div class="layui-input-inline" style="width: 200px;">
  86. <input type="text" id="ssbmmc" name="ssbmmc" >
  87. </div>
  88. </div>
  89. <div class="layui-inline">
  90. <label class="layui-form-label" style="width: 60px">申请时间</label>
  91. <div class="layui-input-inline" style="width: 100px">
  92. <input type="text" name="sqsj1" id="sqsj1" placeholder="开始时间" class="layui-input" readonly>
  93. </div>
  94. <div class="layui-form-mid">-</div>
  95. <div class="layui-input-inline" style="width: 100px">
  96. <input type="text" name="sqsj2" id="sqsj2" placeholder="终止时间" class="layui-input" readonly>
  97. </div>
  98. </div>
  99. <div class="layui-inline" style="margin-left: 0px">
  100. <button type="submit" class="layui-btn" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
  101. <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>
  102. </div>
  103. </div>
  104. </form>
  105. </div>
  106. </fieldset>
  107. <script type="text/html" id="toolbarDemo">
  108. <div class="layui-btn-container">
  109. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="edit">
  110. <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>编辑
  111. </button>
  112. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="view">
  113. <i class="layui-icon layui-icon-file" style="font-size: 10px;"></i>查看
  114. </button>
  115. <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delete">
  116. <i class="layui-icon layui-icon-delete" style="font-size: 10px;"></i>删除
  117. </button>
  118. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="spOption">
  119. <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>审核
  120. </button>
  121. <button class="layui-btn layui-btn-sm data-add-btn" lay-event="tjrevokeApprove">
  122. <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>撤销审批
  123. </button>
  124. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="spList">
  125. <i class="layui-icon layui-icon-list" style="font-size: 10px;"></i>审批列表
  126. </button>
  127. <button class="layui-btn layui-btn-sm layui-bg-black iconfont layui-icon-export" lay-event="export">
  128. <i class="layui-icon" style="font-size: 10px;"></i>导出列表
  129. </button>
  130. <!-- <button class="layui-btn layui-btn-sm" lay-event="exportExcel">-->
  131. <!-- <i class="layui-icon layui-icon-export" style="font-size: 10px;"></i>导出-->
  132. <!-- </button>-->
  133. </div>
  134. </script>
  135. <input type="hidden" id="userId" name="userId" class="layui-input" th:value="${userId}">
  136. <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
  137. </div>
  138. </div>
  139. <script>
  140. // 当文档加载完成后执行以下操作
  141. document.addEventListener('DOMContentLoaded', function() {
  142. // 获取下拉框元素
  143. var selectElement = document.getElementById('nf');
  144. // 获取当前年份并转换为字符串
  145. var currentYear = new Date().getFullYear().toString();
  146. // 遍历下拉框选项
  147. for (var i = 0; i < selectElement.options.length; i++) {
  148. // 如果选项的值与当前年份相匹配,则将该选项设为被选中状态并结束循环
  149. if (selectElement.options[i].value === currentYear) {
  150. selectElement.options[i].selected = true;
  151. break;
  152. }
  153. }
  154. });
  155. </script>
  156. <script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
  157. <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
  158. <script th:src="@{/lib/coco-message/coco-message.js}" charset="utf-8"></script>
  159. <script th:src="@{/js/lay-config.js}" charset="utf-8"></script>
  160. <script th:src="@{/lib/xm-select-v1.2.2/xm-select.js}" charset="utf-8"></script>
  161. <script th:inline="javascript" type="text/javascript">
  162. AjaxUtil.ctx = /*[[@{/}]]*/'';
  163. var updateflag = 0;
  164. var fyApproval = {};
  165. layui.use(['form', 'table', 'tableSelect', 'laydate','layCascader'], function () {
  166. var form = layui.form,
  167. tableSelect = layui.tableSelect,
  168. laydate = layui.laydate,
  169. table = layui.table;
  170. layCascader = layui.layCascader;
  171. var userId = $("#userId").val();
  172. var sqsj1 = '',
  173. sqsj2 = '';
  174. var index2 = layer.load(0, {shade: 0.1});
  175. AjaxUtil.get({
  176. url: AjaxUtil.ctx + 'userinfo/listDeptForSelect',
  177. success: function (res) {
  178. layer.close(index2);
  179. var datalist = [];
  180. for (let item of res.data) {
  181. item.value = item.deptName;
  182. item.label = item.deptName;
  183. datalist.push(item);
  184. }
  185. console.log(datalist)
  186. // 扁平数据转树
  187. var options = arrayToTree(datalist, "0");
  188. // 初始化cascader实例
  189. var cascader = layCascader({
  190. elem: '#ssbmmc',
  191. clearable: true,
  192. showAllLevels: false, // 配置仅显示最后一级
  193. props: {
  194. checkStrictly: true, // 配置选择任意一级选项
  195. },
  196. options: options
  197. });
  198. // 监听cascader变化
  199. cascader.changeEvent(function (value, node) {
  200. // 主动关闭面板
  201. cascader.close();
  202. $("#deptId").val(value);
  203. console.log(node);
  204. });
  205. },
  206. error: function (error) {
  207. layer.close(index2);
  208. Message.error('获取部门信息失败!', 1000);
  209. }
  210. });
  211. //申请时间
  212. laydate.render({
  213. elem: '#sqsj1',
  214. done: function (value, date, endDate) {
  215. sqsj1 = $("#sqsj1").val();
  216. sqsj2 = $("#sqsj2").val();
  217. if (sqsj1 != "" && sqsj2 != "") {
  218. if (sqsj1 > sqsj2) {
  219. Message.warning("起始时间不能晚于终止时间!", 1500);
  220. $("#sqsj1").val("");
  221. }
  222. }
  223. }
  224. });
  225. laydate.render({
  226. elem: '#sqsj2',
  227. done: function (value, date, endDate) {
  228. sqsj1 = $("#sqsj1").val();
  229. sqsj2 = $("#sqsj2").val();
  230. if (sqsj1 != "" && sqsj2 != "") {
  231. if (sqsj1 > sqsj2) {
  232. Message.warning("终止时间不能早于开始时间!", 1500);
  233. $("#sqsj2").val("");
  234. }
  235. }
  236. }
  237. });
  238. //电科院负责人
  239. tableSelect.render({
  240. elem: '#dkyfzrxm',
  241. checkedKey: 'id',
  242. searchKey: 'xm',
  243. searchPlaceholder: '搜索姓名',
  244. table: {
  245. url: AjaxUtil.ctx + 'basePerson/rylist',
  246. cols: [
  247. [
  248. {type: "checkbox", fixed: 'left'},
  249. {type: 'numbers', align: 'center'},
  250. {field: 'xm', width: '15%', title: '姓名', align: 'left'},
  251. {field: 'dwmc', title: '公司/单位', align: 'left'}
  252. ]
  253. ]
  254. },
  255. done: function (elem, data) {
  256. var NEWJSON = [];
  257. var NEWJSON1 = [];
  258. layui.each(data.data, function (index, item) {
  259. NEWJSON.push(item.xm);
  260. NEWJSON1.push(item.id);
  261. })
  262. elem.val(NEWJSON.join(","));
  263. $("#dkyfzr").val(NEWJSON1.join(","));
  264. }
  265. });
  266. var year = document.getElementById('nf').value;
  267. var currTable = table.render({
  268. elem: '#currentTableId',
  269. url: AjaxUtil.ctx + 'staBudgetapproval/list_approving/?nf='+year,
  270. method: 'post',
  271. toolbar: '#toolbarDemo',
  272. // defaultToolbar: ['filter', 'print'],
  273. cols: [
  274. [
  275. {type: "checkbox", fixed: 'left'},
  276. {type: 'numbers', align: 'center', fixed: 'left'},
  277. {field: 'xmmc', width: '20%', title: '项目名称',fixed: "left"},
  278. {field: 'spzt', width: '9%', title: '审批状态', sort: true},
  279. {field: 'bh', width: '8%', title: '科研费号'},
  280. // {field: 'sqmc', width: '25%', title: '申请名称'},
  281. {field: 'erpbh', width: '9%', title: 'ERP编号'},
  282. {field: 'xmlxmc', width: '10%', title: '项目类型'},
  283. {field: 'fylbmc', width: '7%', title: '费用类别'},
  284. {field: 'sqje', width: '7%', title: '申请金额(元)'},
  285. {field: 'sqrxm', width: '5%', title: '申请人'},
  286. {field: 'dkyfzrxm', width: '8%', title: '电科院负责人'},
  287. {field: 'ssbmmc', width: '8%', title: '所属部门'},
  288. {field: 'nf', width: '5%', title: '年份'},
  289. {field: 'sqsj', width: '8%', title: '申请时间', align: 'center'}
  290. ]
  291. ],
  292. autoSort: false,
  293. limits: [10, 15, 20, 25, 50, 100],
  294. limit: 10,
  295. page: true,
  296. skin: 'grid',
  297. parseData: function (res) { //res 即为原始返回的数据
  298. return {
  299. "code": res.code, //解析接口状态
  300. "msg": res.message, //解析提示文本
  301. "count": res.data.total, //解析数据长度
  302. "data": res.data.rows //解析数据列表
  303. };
  304. },
  305. done: function (res, curr, count) { // done为数据渲染完的回调
  306. // 测试打印出后端返回的权限列表
  307. // let permissionSet = [[${permissionSet}]];
  308. // console.log(JSON.stringify(permissionSet));
  309. }
  310. });
  311. // 监听搜索操作
  312. form.on('submit(data-search-btn)', function (data) {
  313. // 执行搜索重载
  314. currTable.reload({
  315. page: {
  316. curr: 1 // 页码从1开始
  317. },
  318. where: form.val("search-form")
  319. });
  320. return false;
  321. });
  322. // 监听重置操作
  323. form.on('submit(data-reset-btn)', function (data) {
  324. form.val("search-form", {
  325. "bh": '',
  326. "erpbh": '',
  327. "xmlx": '',
  328. "sfbyj": '',
  329. "xmmc": '',
  330. "ssbmmc": '',
  331. "nf": '0',
  332. "spzt": '',
  333. "sfbz": '',
  334. "dkyfzr": '',
  335. "dkyfzrxm":'',
  336. "sqsj1":'',
  337. "sqsj2":''
  338. });
  339. // 执行搜索重载
  340. currTable.reload({
  341. page: {
  342. curr: 1
  343. },
  344. where: form.val("search-form")
  345. });
  346. return false;
  347. });
  348. // 监听工具栏事件
  349. table.on('toolbar(currentTableFilter)', function (obj) {
  350. if (obj.event === 'add') { // 监听添加操作
  351. layer.open({
  352. title: '新建费用申请',
  353. type: 2,
  354. shade: 0.3,
  355. maxmin: true,
  356. area: ['1020px', layerheight + 'px'],
  357. content: AjaxUtil.ctx + 'staBudgetapproval/forApplyAdd',
  358. end: function (index) {
  359. // 重载表格
  360. if(updateflag == 1)
  361. currTable.reload();
  362. updateflag =0;
  363. }
  364. });
  365. }
  366. else if (obj.event == 'edit') {
  367. var dataApproval = table.cache["currentTableId"];
  368. if(dataApproval.length == 0)
  369. return;
  370. var checkStatus = table.checkStatus('currentTableId')
  371. , data = checkStatus.data;
  372. if (data == null || data.length === 0) {
  373. Message.warning("请选择要编辑的费用申请!", 1500);
  374. } else if (data.length > 1) {
  375. Message.warning("请选择一条记录进行编辑!", 1500);
  376. } else if (data[0].spzt == "作废") {
  377. Message.warning("该费用申请已作废!", 1500);
  378. } else if (data[0].spzt == "审批结束") {
  379. Message.warning("该费用申请已审批结束,不能修改!", 1500);
  380. } else if (data[0].spzt != null && data[0].spzt.indexOf("未提交") < 0) {
  381. Message.warning("该费用申请审批中,不能修改!", 1500);
  382. } else {
  383. layer.open({
  384. title: '编辑费用申请',
  385. type: 2,
  386. shade: 0.3,
  387. maxmin: true,
  388. shadeClose: true,
  389. area: ['1020px', layerheight + 'px'],
  390. content: AjaxUtil.ctx + 'staBudgetapproval/forApplyUpdate/' + data[0].id,
  391. end: function (index) {
  392. if(updateflag == 1)
  393. currTable.reload();
  394. updateflag =0;
  395. }
  396. });
  397. // layer.full(index);
  398. }
  399. }
  400. else if (obj.event == 'view') {
  401. var dataApproval = table.cache["currentTableId"];
  402. if(dataApproval.length == 0)
  403. return;
  404. var checkStatus = table.checkStatus('currentTableId')
  405. , data = checkStatus.data;
  406. if (data == null || data.length === 0) {
  407. Message.warning("请选择要查看的费用申请!", 1500);
  408. } else if (data.length > 1) {
  409. Message.warning("请选择一条记录进行查看!", 1500);
  410. } else {
  411. layer.open({
  412. title: '浏览费用申请',
  413. type: 2,
  414. shade: 0.3,
  415. maxmin: true,
  416. shadeClose: true,
  417. area: ['1020px', layerheight + 'px'],
  418. content: AjaxUtil.ctx + 'staBudgetapproval/forApplyView/' + data[0].id,
  419. end: function (index) {
  420. layer.close(index);
  421. }
  422. });
  423. // layer.full(index);
  424. }
  425. }
  426. else if (obj.event === 'delete') { // 监听删除操作
  427. var dataApproval = table.cache["currentTableId"];
  428. if(dataApproval.length == 0)
  429. return;
  430. var checkStatus = table.checkStatus('currentTableId')
  431. ,data = checkStatus.data;
  432. if (data == null || data.length === 0) {
  433. Message.warning("请选择要删除的费用申请!", 1500);
  434. return;
  435. } else {
  436. for(let item of data) {
  437. if(item.spzt != "未提交") {
  438. if(item.spzt == "审批结束")
  439. Message.warning("存在已审批结束的费用申请,不能直接删除!", 2000);
  440. else if (data[0].spzt != null)
  441. Message.warning("存在审批中的费用申请,不能直接删除!", 2000);
  442. return;
  443. }
  444. }
  445. }
  446. layer.confirm('确定批量删除费用申请吗?', function (index) {
  447. layer.close(index);
  448. AjaxUtil.post({
  449. url: AjaxUtil.ctx + "staBudgetapproval/batchDelete",
  450. contentType: "application/json",
  451. data: JSON.stringify(data),
  452. success: function (res) {
  453. if (res.code === 0) {
  454. Message.success(1500, res.message, function () {
  455. // 重载表格
  456. currTable.reload();
  457. });
  458. } else {
  459. Message.error(res.message, 1000);
  460. }
  461. },
  462. error: function (error) {
  463. }
  464. });
  465. });
  466. }
  467. else if (obj.event === 'tjApprove') {
  468. var projects = table.cache["currentTableId"];
  469. if (projects.length == 0)
  470. return;
  471. var checkStatus = table.checkStatus('currentTableId')
  472. , data = checkStatus.data;
  473. if (data == null || data.length === 0) {
  474. Message.warning("请选择要提交审批的费用申请!", 2000);
  475. } else if (data.length > 1) {
  476. Message.warning("请选择一条记录进行提交!", 1500);
  477. } else if (data[0].spzt == "审批结束") {
  478. Message.warning("该费用申请已审批结束!", 1500);
  479. } else if (data[0].spzt == "作废") {
  480. Message.warning("该费用申请已作废!", 1500);
  481. } else if (data[0].spzt != null && data[0].spzt.indexOf("未提交") < 0) {
  482. Message.warning("该费用申请正在审批中……", 1500);
  483. } else {
  484. xmApproval = {
  485. "xmid": data[0].id,
  486. "xm": data[0].sqmc,
  487. "zt": data[0].spzt,
  488. "sqje": data[0].sqje
  489. };
  490. if(data[0].spzt == null) {
  491. xmApproval.zt = "未提交";
  492. data[0].spzt = "未提交";
  493. }
  494. var content = AjaxUtil.ctx + 'staBudgetapproval/forApproveAdd';
  495. if (data[0].spzt != "未提交")
  496. content = AjaxUtil.ctx + 'staBudgetapproval/forApproveUpdate/' + data[0].id + '/' + data[0].sqje + '?spzt=' + data[0].spzt;
  497. var index = layer.open({
  498. title: '提交审批',
  499. type: 2,
  500. shade: 0.3,
  501. maxmin: true,
  502. shadeClose: true,
  503. area: ['1025px', layerheight + 'px'],
  504. content: content,
  505. end: function () {
  506. if (updateflag == 1)
  507. currTable.reload();
  508. updateflag = 0;
  509. layer.close(index);
  510. }
  511. });
  512. }
  513. }
  514. else if (obj.event === 'spOption') {
  515. var projects = table.cache["currentTableId"];
  516. if (projects.length == 0)
  517. return;
  518. var checkStatus = table.checkStatus('currentTableId')
  519. , data = checkStatus.data;
  520. if (data == null || data.length === 0) {
  521. Message.warning("请选择要审批的费用申请!", 2000);
  522. } else if (data.length > 1) {
  523. Message.warning("请选择一条记录进行审批!", 1500);
  524. } else if (data[0].spzt == null || data[0].spzt.indexOf("未提交") >= 0) {
  525. Message.warning("该费用申请尚未提交审批!", 1500);
  526. } else if (data[0].spzt == "审批结束") {
  527. Message.warning("该费用申请已审批结束!", 2000);
  528. } else if (data[0].spzt == "作废") {
  529. Message.warning("该费用申请已作废!", 1500);
  530. } else {
  531. xmApproval = {
  532. "xmid": data[0].id,
  533. "xm": data[0].sqmc,
  534. "zt": data[0].spzt,
  535. "sqje": data[0].sqje
  536. };
  537. var content = AjaxUtil.ctx + 'staBudgetapproval/forApproveAdd';
  538. if (data[0].spzt != "未提交")
  539. content = AjaxUtil.ctx + 'staBudgetapproval/forApproveUpdate/' + data[0].id + '/' + data[0].sqje + '?spzt=' + data[0].spzt;
  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: content,
  548. end: function (index) {
  549. if (updateflag == 1)
  550. currTable.reload();
  551. updateflag = 0;
  552. }
  553. });
  554. }
  555. }
  556. else if (obj.event === 'spList') {
  557. var projects = table.cache["currentTableId"];
  558. if (projects.length == 0)
  559. return;
  560. var checkStatus = table.checkStatus('currentTableId')
  561. , data = checkStatus.data;
  562. if (data == null || data.length === 0) {
  563. Message.warning("请选择要查看审批列表的费用申请!", 1500);
  564. } else if (data.length > 1) {
  565. Message.warning("请选择一条记录进行查看!", 1500);
  566. } else if (data[0].spzt == null || data[0].spzt == "未提交") {
  567. Message.warning("该备费用申请尚未提交审批!", 1500);
  568. } else {
  569. xmApproval = {
  570. "xmid": data[0].id,
  571. "xm": data[0].sqmc,
  572. "zt": data[0].spzt,
  573. "sqje": data[0].sqje
  574. };
  575. var index = layer.open({
  576. title: '审批列表',
  577. type: 2,
  578. shade: 0.3,
  579. maxmin: true,
  580. shadeClose: true,
  581. area: ['1300px', layerheight + 'px'],
  582. content: AjaxUtil.ctx + 'staBudgetapproval/forApproveList',
  583. end: function () {
  584. layer.close(index);
  585. }
  586. });
  587. }
  588. }
  589. else if (obj.event === 'reimburse') {
  590. var projects = table.cache["currentTableId"];
  591. if (projects.length == 0)
  592. return;
  593. var checkStatus = table.checkStatus('currentTableId')
  594. , data = checkStatus.data;
  595. if (data == null || data.length === 0) {
  596. Message.warning("请选择要报账的费用申请!", 1500);
  597. } else if (data.length > 1) {
  598. Message.warning("请选择一条记录进行报账!", 1500);
  599. } else if (data[0].spzt == "作废") {
  600. Message.warning("该费用申请已作废!", 1500);
  601. } else if (data[0].spzt.indexOf("未提交") >= 0) {
  602. Message.warning("该费用申请尚未提交审批!", 1500);
  603. } else if (data[0].spzt != "审批结束") {
  604. Message.warning("该费用申请正在审批中……", 1500);
  605. } else if (data[0].sfbz == 1) {
  606. Message.warning("该费用申请已报账", 1500);
  607. } else {
  608. var index = layer.open({
  609. title: '新建报账',
  610. type: 2,
  611. shade: 0.3,
  612. maxmin: true,
  613. shadeClose: true,
  614. area: ['970px', '750px'],
  615. content: AjaxUtil.ctx + "staReimbursement/forAdd/" +data[0].id,
  616. end: function () {
  617. if (updateflag == 1)
  618. currTable.reload();
  619. updateflag = 0;
  620. layer.close(index);
  621. }
  622. });
  623. }
  624. } else if (obj.event === 'nullify') { // 监听作废操作
  625. var projects = table.cache["currentTableId"];
  626. if (projects.length == 0)
  627. return;
  628. var checkStatus = table.checkStatus('currentTableId')
  629. , data = checkStatus.data;
  630. if (data == null || data.length === 0)
  631. Message.warning("请选择要作废的费用申请!", 1000);
  632. else {
  633. layer.confirm('确定批量作废费用申请吗?', function (index) {
  634. layer.close(index);
  635. AjaxUtil.post({
  636. url: AjaxUtil.ctx + "staBudgetapproval/batchNullify",
  637. contentType: "application/json",
  638. data: JSON.stringify(data),
  639. success: function (res) {
  640. if (res.code === 0) {
  641. Message.success(1500, res.message, function () {
  642. // 重载表格
  643. currTable.reload();
  644. });
  645. } else {
  646. Message.error(res.message, 1000);
  647. }
  648. },
  649. error: function (error) {
  650. }
  651. });
  652. });
  653. }
  654. }
  655. else if(obj.event==='tjrevokeApprove'){
  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 if (data[0].spzt == "审批结束") {
  666. Message.warning("该任务书已审批结束!", 1500);
  667. } else if (data[0].cjr != userId) {
  668. Message.error("您不是该任务书的创建人!", 1500);
  669. } else {
  670. xmApproval = {
  671. "xmid": data[0].id,
  672. "xm": data[0].zwmc,
  673. "zt": "未提交"
  674. };
  675. if(data[0].spzt == null) {
  676. xmApproval.zt = "未提交";
  677. data[0].spzt = "未提交";
  678. }
  679. var project = {
  680. "id": xmApproval.xmid,
  681. "spzt": '未提交'
  682. }
  683. layer.confirm('确定撤销项目任务书吗?', function (index) {
  684. layer.close(index);
  685. AjaxUtil.post({
  686. url: AjaxUtil.ctx + "prjProject/TJrevokeApprove",
  687. contentType: "application/json",
  688. data: JSON.stringify(project),
  689. success: function (res) {
  690. if (res.code === 0) {
  691. Message.success(1500, res.message, function () {
  692. // 重载表格
  693. currTable.reload();
  694. });
  695. } else {
  696. Message.error(res.message, 1000);
  697. }
  698. },
  699. error: function (error) {
  700. }
  701. });
  702. });
  703. }
  704. }else if (obj.event === 'export'){
  705. var formData = form.val('search-form');
  706. // 获取form 表单代码
  707. console.log(formData);
  708. var formDataString = JSON.stringify(formData);
  709. AjaxUtil.post({
  710. url:AjaxUtil.ctx +'staBudgetapproval/getAll/'+formDataString,
  711. contentType: "application/json",
  712. timeout: 15000, //大批量导出时会出现超时问题
  713. success: function(res){
  714. console.log(res);
  715. table.exportFile('currentTableId',res.data,'xlsx');
  716. },
  717. error:function (error) {
  718. Message.error(error,2000)
  719. }
  720. });
  721. }
  722. });
  723. //双击
  724. table.on('rowDouble(currentTableFilter)', function (obj) {
  725. var data = obj.data;
  726. layer.open({
  727. title: '浏览费用申请',
  728. type: 2,
  729. shade: 0.3,
  730. maxmin: true,
  731. shadeClose: true,
  732. area: ['1020px', layerheight + 'px'],
  733. content: AjaxUtil.ctx + 'staBudgetapproval/forApplyView/' + data.id,
  734. end: function (index) {
  735. layer.close(index);
  736. }
  737. });
  738. });
  739. });
  740. // 监听表格选框事件
  741. // table.on
  742. function setUpdateFlag() {
  743. updateflag = 1;
  744. }
  745. function getXmApproval() {
  746. return xmApproval;
  747. }
  748. function arrayToTree(data, firstPid) {
  749. const result = [];
  750. getChildren(data, result, firstPid)
  751. return result;
  752. }
  753. function getChildren(data, result, parentId) {
  754. for (const item of data) {
  755. if (item.parentId === parentId) {
  756. const newItem = {...item, children: []};
  757. result.push(newItem);
  758. getChildren(data, newItem.children, item.deptId);
  759. }
  760. }
  761. }
  762. </script>
  763. </body>
  764. </html>