list_allapply.html 40 KB

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