list_imprest_my.html 35 KB

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