list_apply.html 37 KB

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