list_allapply.html 44 KB

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