123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861 |
- <!DOCTYPE html>
- <html lang="en" xmlns:th="http://www.thymeleaf.org">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
- <title>备用金申请</title>
- <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
- <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
- <link rel="stylesheet" th:href="@{/lib/font-awesome-4.7.0/css/font-awesome.min.css}" media="all">
- </head>
- <body>
- <div class="layuimini-container">
- <div class="layuimini-main">
- <fieldset class="table-search-fieldset">
- <legend>搜索信息(<b>收起-展开</b>)</legend>
- <div id="search-div" style="margin: 5px 10px -10px 0px">
- <form class="layui-form" action="" lay-filter="search-form">
- <div class="layui-form-item" >
- <div class="layui-inline">
- <label class="layui-form-label" style="width: 60px">项目名称</label>
- <div class="layui-input-inline" style="width: 200px">
- <input type="text" id="xmmc" name="xmmc" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-inline">
- <label class="layui-form-label" style="width: 60px; margin-left: -10px">ERP编号</label>
- <div class="layui-input-inline" style="width: 150px">
- <input type="text" id="erpbh" name="erpbh" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-inline">
- <label class="layui-form-label" style="width: 60px; margin-left: -10px">申请编号</label>
- <div class="layui-input-inline" style="width: 150px">
- <input type="text" id="bh" name="bh" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-inline">
- <label class="layui-form-label" style="width: 30px; margin-left: -10px">年份</label>
- <div class="layui-input-inline" style="width: 100px">
- <select name="nf" id="nf" lay-filter="status">
- <option value="">全部</option>
- <option th:each="item:${yearList}" th:text="${item.nf}" th:value="${item.nf}"></option>
- </select>
- </div>
- </div>
- <div class="layui-inline">
- <label class="layui-form-label" style="width: 60px; margin-left: -10px">审批状态</label>
- <div class="layui-input-inline" style="width: 150px">
- <select name="spzt" id="spzt" lay-filter="status">
- <option value="">全部</option>
- <option th:each="item:${approveList}" th:text="${item.name}" th:value="${item.name}"></option>
- </select>
- </div>
- </div>
- <div class="layui-inline" style="margin-left: 0px">
- <button type="submit" class="layui-btn" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
- <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>
- </div>
- </div>
- </form>
- </div>
- </fieldset>
- <script type="text/html" id="toolbarDemo">
- <div class="layui-btn-container">
- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="edit">
- <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>编辑
- </button>
- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="view">
- <i class="layui-icon layui-icon-file" style="font-size: 10px;"></i>查看
- </button>
- <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delete">
- <i class="layui-icon layui-icon-delete" style="font-size: 10px;"></i>删除
- </button>
- <button class="layui-btn layui-btn-sm data-add-btn" lay-event="tjrevokeApprove">
- <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>撤销审批
- </button>
- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="spOption">
- <i class="layui-icon layui-icon-edit" style="font-size: 10px;"></i>审核
- </button>
- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="spList">
- <i class="layui-icon layui-icon-list" style="font-size: 10px;"></i>审批列表
- </button>
- <button class="layui-btn layui-btn-sm data-add-btn" lay-event="connect">
- <i class="layui-icon layui-icon-link" style="font-size: 10px;"></i>关联项目
- </button>
- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="disconnect">
- <i class="layui-icon layui-icon-unlink" style="font-size: 10px;"></i>取消关联
- </button>
- <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="associated">
- <i class="layui-icon layui-icon-list" style="font-size: 10px;"></i>待关联项目
- </button>
- <!-- <button class="layui-btn layui-btn-sm" lay-event="exportExcel">-->
- <!-- <i class="layui-icon layui-icon-export" style="font-size: 10px;"></i>导出-->
- <!-- </button>-->
- </div>
- </script>
- <input type="hidden" id="userId" name="userId" class="layui-input" th:value="${userId}">
- <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
- </div>
- </div>
- <script>
- // 当文档加载完成后执行以下操作
- document.addEventListener('DOMContentLoaded', function() {
- // 获取下拉框元素
- var selectElement = document.getElementById('nf');
- // 获取当前年份并转换为字符串
- var currentYear = new Date().getFullYear().toString();
- // 遍历下拉框选项
- for (var i = 0; i < selectElement.options.length; i++) {
- // 如果选项的值与当前年份相匹配,则将该选项设为被选中状态并结束循环
- if (selectElement.options[i].value === currentYear) {
- selectElement.options[i].selected = true;
- break;
- }
- }
- });
- </script>
- <script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
- <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
- <script th:src="@{/lib/coco-message/coco-message.js}" charset="utf-8"></script>
- <script th:src="@{/js/lay-config.js}" charset="utf-8"></script>
- <script th:src="@{/lib/xm-select-v1.2.2/xm-select.js}" charset="utf-8"></script>
- <script th:inline="javascript" type="text/javascript">
- AjaxUtil.ctx = /*[[@{/}]]*/'';
- var updateflag = 0;
- var xmApproval = {};
- layui.use(['form', 'table'], function () {
- var form = layui.form,
- table = layui.table;
- var userId = $("#userId").val();
- var year = document.getElementById('nf').value;
- var currTable = table.render({
- elem: '#currentTableId',
- url: AjaxUtil.ctx + 'staBudgetapproval/list_imprest1/?nf='+year,
- method: 'post',
- toolbar: '#toolbarDemo',
- // defaultToolbar: ['filter', 'print'],
- cols: [
- [
- {type: "checkbox", fixed: 'left'},
- {type: 'numbers', align: 'center', fixed: 'left'},
- {field: 'xmmc', width: '15%',title: '项目名称',fixed: "left"},
- {field: 'spzt', width: '10%',title: '审批状态', sort: true},
- {field: 'bh', width: '9%',title: '编号'},
- {field: 'sqmc', width: '25%', title: '申请名称'},
- {field: 'nf', width: '5%', title: '年份'},
- {field: 'sqje', width: '7%', title: '申请金额(元)'},
- {field: 'bzje', width: '7%', title: '报账金额(元)'},
- // {field: 'bhsje', width: '9%', title: '不含税金额(元)'},
- {field: 'erpbh', width: '9%', title: 'ERP编号'},
- {field: 'xmmc', width: '20%', title: '项目名称'},
- {field: 'fylbmc', width: '7%', title: '费用类别'},
- {field: 'sqrxm', width: '8%', title: '申请人'},
- {field: 'sqsj', width: '8%', title: '申请时间', align: 'center'}
- ]
- ],
- autoSort: false,
- limits: [10, 15, 20, 25, 50, 100],
- limit: 10,
- page: true,
- skin: 'grid',
- parseData: function(res){ //res 即为原始返回的数据
- return {
- "code": res.code, //解析接口状态
- "msg": res.message, //解析提示文本
- "count": res.data.total, //解析数据长度
- "data": res.data.rows //解析数据列表
- };
- },
- done: function(res, curr, count) { // done为数据渲染完的回调
- // 测试打印出后端返回的权限列表
- // let permissionSet = [[${permissionSet}]];
- // console.log(JSON.stringify(permissionSet));
- }
- });
- // 监听搜索操作
- form.on('submit(data-search-btn)', function (data) {
- // 执行搜索重载
- currTable.reload({
- page: {
- curr: 1 // 页码从1开始
- },
- where: form.val("search-form")
- });
- return false;
- });
- // 监听重置操作
- form.on('submit(data-reset-btn)', function (data) {
- form.val("search-form", {
- "xmmc": '',
- "spzt": '',
- "erpbh": '',
- "bh": '',
- "nf": ''
- });
- // 执行搜索重载
- currTable.reload({
- page: {
- curr: 1
- },
- where: form.val("search-form")
- });
- return false;
- });
- // 监听排序事件
- table.on('sort(currentTableFilter)', function(obj){ //注:sort 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值"
- // console.log(obj.field); //当前排序的字段名
- // console.log(obj.type); //当前排序类型:desc(降序)、asc(升序)、null(空对象,默认排序)
- // console.log(this); //当前排序的 th 对象
- //尽管我们的 table 自带排序功能,但并没有请求服务端。
- //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如:
- currTable.reload({
- initSort: obj, //记录初始排序,如果不设的话,将无法标记表头的排序状态。
- where: { //请求参数(注意:这里面的参数可任意定义,并非下面固定的格式)
- sortName: toLine(obj.field), //排序字段
- sortOrder: toLine(obj.type) //排序方式
- }
- });
- });
- // 监听工具栏事件
- table.on('toolbar(currentTableFilter)', function (obj) {
- if (obj.event === 'add') { // 监听添加操作
- layer.open({
- title: '新建备用金申请',
- type: 2,
- shade: 0.3,
- // maxmin: true,
- area: [layerwidth + 'px', layerheight + 'px'],
- content: AjaxUtil.ctx + 'staBudgetapproval/forImprestAdd',
- end: function (index) {
- // 重载表格
- if (updateflag == 1)
- currTable.reload();
- updateflag = 0;
- }
- });
- // layer.full(index);
- } else if (obj.event == 'edit') {
- var dataApproval = table.cache["currentTableId"];
- if (dataApproval.length == 0)
- return;
- var checkStatus = table.checkStatus('currentTableId')
- , data = checkStatus.data;
- if (data == null || data.length === 0) {
- Message.warning("请选择要编辑的备用金申请!", 1500);
- } else if (data.length > 1) {
- Message.warning("请选择一条记录进行编辑!", 1500);
- } else if (data[0].spzt == "作废") {
- Message.warning("该备用金申请已作废!", 1500);
- } else if (data[0].spzt == "审批结束") {
- Message.warning("该备用金申请已审批结束,不能修改!", 1500);
- } else if (data[0].spzt != null && data[0].spzt.indexOf("未提交") < 0) {
- Message.warning("该备用金申请审批中,不能修改!", 1500);
- } else if (data[0].sqr != userId) {
- Message.error("您不是该备用金的申请人,不能修改!", 1500);
- } else {
- layer.open({
- title: '编辑备用金申请',
- type: 2,
- shade: 0.3,
- maxmin: true,
- shadeClose: true,
- area: [layerwidth + 'px', layerheight + 'px'],
- content: AjaxUtil.ctx + 'staBudgetapproval/forImprestUpdate/' + data[0].id,
- end: function (index) {
- if (updateflag == 1)
- currTable.reload();
- updateflag = 0;
- }
- });
- }
- } else if (obj.event == 'view') {
- var dataApproval = table.cache["currentTableId"];
- if (dataApproval.length == 0)
- return;
- var checkStatus = table.checkStatus('currentTableId')
- , data = checkStatus.data;
- if (data == null || data.length === 0) {
- Message.warning("请选择要查看的备用金申请!", 1500);
- } else if (data.length > 1) {
- Message.warning("请选择一条记录进行查看!", 1500);
- } else {
- var width = layerwidth + 'px';
- var content = AjaxUtil.ctx + 'staBudgetapproval/forImprestView/' + data[0].id;
- if (data[0].fylbmc != null) {
- width = '1020px';
- content = AjaxUtil.ctx + 'staBudgetapproval/forApplyView/' + data[0].id;
- }
- layer.open({
- title: '浏览备用金申请',
- type: 2,
- shade: 0.3,
- maxmin: true,
- shadeClose: true,
- area: [width, layerheight + 'px'],
- content: content,
- end: function (index) {
- layer.close(index);
- }
- });
- }
- } else if (obj.event === 'delete') { // 监听删除操作
- var projects = table.cache["currentTableId"];
- if (projects.length == 0)
- return;
- var checkStatus = table.checkStatus('currentTableId')
- , data = checkStatus.data;
- if (data == null || data.length === 0) {
- Message.warning("请选择备用金申请!", 1000);
- return;
- } else {
- for (let item of data) {
- if(item.sqr != userId) {
- Message.error("存在您不是申请人的备用金,不能直接删除!", 2000);
- return;
- }
- if (item.spzt != "未提交") {
- if (item.spzt == "审批结束")
- Message.error("存在已审批结束的备用金申请,不能直接删除!", 2000);
- else if (data[0].spzt != null)
- Message.error("存在审批中的备用金申请,不能直接删除!", 2000);
- return;
- }
- }
- }
- layer.confirm('确定批量删除备用金申请吗?', function (index) {
- layer.close(index);
- AjaxUtil.post({
- url: AjaxUtil.ctx + "staBudgetapproval/batchDelete",
- contentType: "application/json",
- data: JSON.stringify(data),
- success: function (res) {
- if (res.code === 0) {
- Message.success(1500, res.message, function () {
- // 重载表格
- currTable.reload();
- });
- } else {
- Message.error(res.message, 1000);
- }
- },
- error: function (error) {
- }
- });
- });
- } else if (obj.event === 'tjApprove') {
- var projects = table.cache["currentTableId"];
- if (projects.length == 0)
- return;
- var checkStatus = table.checkStatus('currentTableId')
- , data = checkStatus.data;
- if (data == null || data.length === 0) {
- Message.warning("请选择要提交审批的备用金申请!", 2000);
- } else if (data.length > 1) {
- Message.warning("请选择一条记录进行提交!", 1500);
- } else if (data[0].spzt == "审批结束") {
- Message.warning("该备用金申请已审批结束!", 1500);
- } else if (data[0].spzt == "作废") {
- Message.warning("该备用金申请已作废!", 1500);
- } else if (data[0].spzt != null && data[0].spzt.indexOf("未提交") < 0) {
- Message.warning("该备用金申请正在审批中……", 1500);
- } else if (data[0].sqr != userId) {
- Message.error("您不是该备用金的申请人!", 1500);
- } else {
- xmApproval = {
- "xmid": data[0].id,
- "xm": data[0].sqmc,
- "zt": data[0].spzt,
- "sqje": data[0].sqje
- };
- if (data[0].spzt == null) {
- xmApproval.zt = "未提交";
- data[0].spzt = "未提交";
- }
- var content = AjaxUtil.ctx + 'staBudgetapproval/forApproveAdd1';
- if (data[0].spzt != "未提交")
- content = AjaxUtil.ctx + 'staBudgetapproval/forApproveUpdate1/' + data[0].id + '/' + data[0].sqje + '?spzt=' + data[0].spzt;
- var index = layer.open({
- title: '提交审批',
- type: 2,
- shade: 0.3,
- maxmin: true,
- shadeClose: true,
- area: ['1025px', layerheight + 'px'],
- content: content,
- end: function () {
- if (updateflag == 1)
- currTable.reload();
- updateflag = 0;
- layer.close(index);
- }
- });
- }
- } else if (obj.event === 'spOption') {
- var projects = table.cache["currentTableId"];
- if (projects.length == 0)
- return;
- var checkStatus = table.checkStatus('currentTableId')
- , data = checkStatus.data;
- if (data == null || data.length === 0) {
- Message.warning("请选择要审批的备用金申请!", 1500);
- } else if (data.length > 1) {
- Message.warning("请选择一条记录进行审批!", 1500);
- } else if (data[0].spzt == null || data[0].spzt.indexOf("未提交") >= 0) {
- Message.warning("该备用金申请尚未提交审批!", 1500);
- } else if (data[0].spzt == "审批结束") {
- Message.warning("该备用金申请已审批结束!", 1500);
- } else if (data[0].spzt == "作废") {
- Message.warning("该备用金已作废!", 1500);
- } else {
- xmApproval = {
- "xmid": data[0].id,
- "xm": data[0].sqmc,
- "zt": data[0].spzt,
- "sqje": data[0].sqje
- };
- var content = AjaxUtil.ctx + 'staBudgetapproval/forApproveUpdate1/' + data[0].id + '/' + data[0].sqje + '?spzt=' + data[0].spzt;
- layer.open({
- title: '审批意见',
- type: 2,
- shade: 0.3,
- maxmin: true,
- shadeClose: true,
- area: ['1025px', layerheight + 'px'],
- content: content,
- end: function (index) {
- if (updateflag == 1)
- currTable.reload();
- updateflag = 0;
- }
- });
- }
- } else if (obj.event === 'spList') {
- var projects = table.cache["currentTableId"];
- if (projects.length == 0)
- return;
- var checkStatus = table.checkStatus('currentTableId')
- , data = checkStatus.data;
- if (data == null || data.length === 0) {
- Message.warning("请选择要查看审批列表的备用金申请!", 1500);
- } else if (data.length > 1) {
- Message.warning("请选择一条记录进行查看!", 1500);
- } else if (data[0].spzt == null || data[0].spzt == "未提交") {
- Message.warning("该备用金申请尚未提交审批!", 1500);
- } else {
- xmApproval = {
- "xmid": data[0].id,
- "xm": data[0].sqmc,
- "zt": data[0].spzt,
- "sqje": data[0].sqje
- };
- var index = layer.open({
- title: '审批列表',
- type: 2,
- shade: 0.3,
- maxmin: true,
- shadeClose: true,
- area: ['1300px', layerheight + 'px'],
- content: AjaxUtil.ctx + 'staBudgetapproval/forApproveList1',
- end: function () {
- layer.close(index);
- }
- });
- }
- // } else if (obj.event === 'connect') {
- // var projects = table.cache["currentTableId"];
- // if (projects.length == 0)
- // return;
- //
- // var checkStatus = table.checkStatus('currentTableId')
- // , data = checkStatus.data;
- // if (data == null || data.length === 0) {
- // Message.warning("请选择要关联项目的备用金申请!", 1500);
- // } else if (data.length > 1) {
- // Message.warning("请选择一条记录关联项目!", 1500);
- // } else if (data[0].spzt == "作废") {
- // Message.warning("该费用备用金已作废!", 1500);
- // } else if (data[0].spzt.indexOf("未提交") >= 0) {
- // Message.warning("该备用金申请尚未提交审批!", 1500);
- // } else if (data[0].spzt != "审批结束") {
- // Message.warning("该备用金申请正在审批中……", 1500);
- // } else if (data[0].sqr != userId) {
- // Message.error("您不是该备用金的申请人!", 1500);
- // } else if (data[0].fylb != null) {
- // Message.warning("该备用金已关联项目!", 1500);
- // } else if (data[0].sfbz == 1) {
- // Message.warning("该备用金已报账!", 1500);
- // } else {
- // layer.open({
- // title: '备用金关联项目',
- // type: 2,
- // shade: 0.3,
- // maxmin: true,
- // area: ['1020px', layerheight + 'px'],
- // content: AjaxUtil.ctx + 'staBudgetapproval/forByjConnect/' + data[0].id,
- // end: function (index) {
- // // 重载表格
- // if(updateflag == 1)
- // currTable.reload();
- // updateflag = 0;
- // layer.close(index);
- // }
- // });
- // }
- // } else if(obj.event === 'disconnect') {
- // var projects = table.cache["currentTableId"];
- // if (projects.length == 0)
- // return;
- //
- // var checkStatus = table.checkStatus('currentTableId')
- // , data = checkStatus.data;
- // if (data == null || data.length === 0) {
- // Message.warning("请选择要取消关联的备用金申请!", 1500);
- // } else if (data.length > 1) {
- // Message.warning("请选择一条记录进行操作!", 1500);
- // } else if (data[0].spzt == "作废") {
- // Message.warning("该备用金申请已作废!", 1500);
- // } else if (data[0].spzt.indexOf("未提交") >= 0) {
- // Message.warning("该备用金申请尚未提交审批!", 1500);
- // } else if (data[0].spzt != "审批结束") {
- // Message.warning("该备用金申请正在审批中……", 1500);
- // } else if (data[0].sqr != userId) {
- // Message.error("您不是该备用金的申请人!", 1500);
- // } else if (data[0].fylb == null) {
- // Message.warning("该备用金尚未关联项目!", 1500);
- // } else if (data[0].sfbz == 1) {
- // Message.warning("该备用金已报账!", 1500);
- // } else {
- // AjaxUtil.post({
- // url: AjaxUtil.ctx + "staBudgetapproval/DisConnect/" + data[0].id,
- // contentType: "application/json",
- // data: JSON.stringify(data),
- // success: function (res) {
- // if (res.code === 0) {
- // Message.success(1500, res.message, function () {
- // // 重载表格
- // currTable.reload();
- // });
- // } else {
- // Message.error(res.message, 1000);
- // }
- // },
- // error: function (error) {
- // }
- // });
- // }
- }
- else if (obj.event === 'connect') {
- var projects = table.cache["currentTableId"];
- if (projects.length == 0)
- return;
- var checkStatus = table.checkStatus('currentTableId')
- , data = checkStatus.data;
- if (data == null || data.length === 0) {
- Message.warning("请选择要关联项目的备用金申请!", 1500);
- } else if (data.length > 1) {
- Message.warning("请选择一条记录关联项目!", 1500);
- } else if (data[0].spzt == "作废") {
- Message.warning("该费用备用金已作废!", 1500);
- } else if (data[0].spzt.indexOf("未提交") >= 0) {
- Message.warning("该备用金申请尚未提交审批!", 1500);
- } else if (data[0].spzt != "审批结束") {
- Message.warning("该备用金申请正在审批中……", 1500);
- } else if (userId != 42) {
- Message.error("您没有关联项目权限,请联系科技项目管理专责审批!", 2000);
- } else if (data[0].fylb != null) {
- Message.warning("该备用金已关联项目!", 1500);
- } else if (data[0].sfbz == 1) {
- Message.warning("该备用金已报账!", 1500);
- } else {
- layer.open({
- title: '备用金关联项目',
- type: 2,
- shade: 0.3,
- maxmin: true,
- area: ['1020px', layerheight + 'px'],
- content: AjaxUtil.ctx + 'staBudgetapproval/forByjConnect/' + data[0].id,
- end: function (index) {
- // 重载表格
- if(updateflag == 1)
- currTable.reload();
- updateflag = 0;
- layer.close(index);
- }
- });
- }
- } else if(obj.event === 'disconnect') {
- var projects = table.cache["currentTableId"];
- if (projects.length == 0)
- return;
- var checkStatus = table.checkStatus('currentTableId')
- , data = checkStatus.data;
- if (data == null || data.length === 0) {
- Message.warning("请选择要取消关联的备用金申请!", 1500);
- } else if (data.length > 1) {
- Message.warning("请选择一条记录进行操作!", 1500);
- } else if (data[0].spzt == "作废") {
- Message.warning("该备用金申请已作废!", 1500);
- } else if (data[0].spzt.indexOf("未提交") >= 0) {
- Message.warning("该备用金申请尚未提交审批!", 1500);
- } else if (data[0].spzt != "审批结束") {
- Message.warning("该备用金申请正在审批中……", 1500);
- } else if (userId != 42) {
- Message.error("您不是该备用金的申请人!", 1500);
- } else if (data[0].fylb == null) {
- Message.warning("该备用金尚未关联项目!", 1500);
- } else if (data[0].sfbz == 1) {
- Message.warning("该备用金已报账!", 1500);
- } else {
- AjaxUtil.post({
- url: AjaxUtil.ctx + "staBudgetapproval/DisConnect/" + data[0].id,
- contentType: "application/json",
- data: JSON.stringify(data),
- success: function (res) {
- if (res.code === 0) {
- Message.success(1500, res.message, function () {
- // 重载表格
- currTable.reload();
- });
- } else {
- Message.error(res.message, 1000);
- }
- },
- error: function (error) {
- }
- });
- }
- }else if (obj.event === 'reimburse') {
- var projects = table.cache["currentTableId"];
- if (projects.length == 0)
- return;
- var checkStatus = table.checkStatus('currentTableId')
- , data = checkStatus.data;
- if (data == null || data.length === 0) {
- Message.warning("请选择要报账的备用金申请!", 1500);
- } else if (data.length > 1) {
- Message.warning("请选择一条记录进行报账!", 1500);
- } else if (data[0].spzt == "作废") {
- Message.warning("该备用金申请已作废!", 1500);
- } else if (data[0].spzt.indexOf("未提交") >= 0) {
- Message.warning("该备用金申请尚未提交审批!", 1500);
- } else if (data[0].spzt != "审批结束") {
- Message.warning("该备用金申请正在审批中……", 1500);
- } else if (data[0].sqr != userId) {
- Message.error("您不是该备用金的申请人!", 1500);
- } else if (data[0].fylb == null) {
- Message.warning("该备用金尚未关联项目!", 1500);
- } else if (data[0].sfbz == 1) {
- Message.warning("该备用金已报账!", 1500);
- } else {
- var index = layer.open({
- title: '新建报账',
- type: 2,
- shade: 0.3,
- maxmin: true,
- shadeClose: true,
- area: ['970px', '750px'],
- content: AjaxUtil.ctx + "staReimbursement/forAdd/" +data[0].id,
- end: function () {
- if (updateflag == 1)
- currTable.reload();
- updateflag = 0;
- layer.close(index);
- }
- });
- }
- } else if (obj.event === 'nullify') { // 监听作废操作
- var projects = table.cache["currentTableId"];
- if (projects.length == 0)
- return;
- var checkStatus = table.checkStatus('currentTableId')
- , data = checkStatus.data;
- if (data == null || data.length === 0)
- Message.warning("请选择要作废的备用金申请!", 1000);
- else {
- layer.confirm('确定批量作废备用金申请吗?', function (index) {
- layer.close(index);
- AjaxUtil.post({
- url: AjaxUtil.ctx + "staBudgetapproval/batchNullify",
- contentType: "application/json",
- data: JSON.stringify(data),
- success: function (res) {
- if (res.code === 0) {
- Message.success(1500, res.message, function () {
- // 重载表格
- currTable.reload();
- });
- } else {
- Message.error(res.message, 1000);
- }
- },
- error: function (error) {
- }
- });
- });
- }
- }
- else if(obj.event==='tjrevokeApprove'){
- var projects = table.cache["currentTableId"];
- if (projects.length == 0)
- return;
- var checkStatus = table.checkStatus('currentTableId')
- , data = checkStatus.data;
- if (data == null || data.length === 0) {
- Message.warning("请选择要撤销的备用金申请!", 1500);
- } else if (data.length > 1) {
- Message.warning("请选择一条记录进行撤销!", 1500);
- } else if (data[0].spzt == "审批结束") {
- Message.warning("该备用金申请已审批结束!", 1500);
- }
- //else if (data[0].sqr != userId) {
- // Message.error("您不是该备用金申请的创建人!", 1500);}
- else {
- xmApproval = {
- "xmid": data[0].id,
- "xm": data[0].zwmc,
- "zt": "未提交"
- };
- if(data[0].spzt == null) {
- xmApproval.zt = "未提交";
- data[0].spzt = "未提交";
- }
- var project = {
- "id": xmApproval.xmid,
- "spzt": '未提交'
- }
- layer.confirm('确定撤销备用金申请吗?', function (index) {
- layer.close(index);
- AjaxUtil.post({
- url: AjaxUtil.ctx + "staBudgetapproval/TJrevokeApprove",
- contentType: "application/json",
- data: JSON.stringify(project),
- success: function (res) {
- if (res.code === 0) {
- Message.success(1500, res.message, function () {
- // 重载表格
- currTable.reload();
- });
- } else {
- Message.error(res.message, 1000);
- }
- },
- error: function (error) {
- }
- });
- });
- }
- }else if(obj.event==='associated'){
- var formData = form.val('search-form');
- console.log(formData);
- var formDataString = JSON.stringify(formData);
- console.log(formDataString);
- var currTable = table.render({
- elem: '#currentTableId',
- url: AjaxUtil.ctx + 'staBudgetapproval/unassociated/' + formDataString,
- method: 'post',
- toolbar: '#toolbarDemo',
- // defaultToolbar: ['filter', 'print'],
- cols: [
- [
- {type: "checkbox", fixed: 'left'},
- {type: 'numbers', align: 'center', fixed: 'left'},
- {field: 'spzt', width: '10%',title: '审批状态', sort: true},
- {field: 'bh', width: '9%',title: '编号'},
- {field: 'sqmc', width: '25%', title: '申请名称'},
- {field: 'nf', width: '5%', title: '年份'},
- {field: 'sqje', width: '7%', title: '申请金额(元)'},
- {field: 'bzje', width: '7%', title: '报账金额(元)'},
- // {field: 'bhsje', width: '9%', title: '不含税金额(元)'},
- {field: 'erpbh', width: '9%', title: 'ERP编号'},
- {field: 'xmmc', width: '20%', title: '项目名称'},
- {field: 'fylbmc', width: '7%', title: '费用类别'},
- {field: 'sqrxm', width: '8%', title: '申请人'},
- {field: 'sqsj', width: '8%', title: '申请时间', align: 'center'}
- ]
- ],
- autoSort: false,
- limits: [10, 15, 20, 25, 50, 100],
- limit: 10,
- page: true,
- skin: 'grid',
- parseData: function(res){ //res 即为原始返回的数据
- return {
- "code": res.code, //解析接口状态
- "msg": res.message, //解析提示文本
- "count": res.data.total, //解析数据长度
- "data": res.data.rows //解析数据列表
- };
- },
- done: function(res, curr, count) { // done为数据渲染完的回调
- // 测试打印出后端返回的权限列表
- // let permissionSet = [[${permissionSet}]];
- // console.log(JSON.stringify(permissionSet));
- }
- })
- }
- });
- //双击
- table.on('rowDouble(currentTableFilter)', function (obj) {
- var data = obj.data;
- var width = layerwidth + 'px';
- var content = AjaxUtil.ctx + 'staBudgetapproval/forImprestView/' + data.id;
- if (data.fylbmc != null) {
- width = '1020px';
- content = AjaxUtil.ctx + 'staBudgetapproval/forApplyView/' + data.id;
- }
- layer.open({
- title: '浏览备用金申请',
- type: 2,
- shade: 0.3,
- maxmin: true,
- shadeClose: true,
- area: [width, layerheight + 'px'],
- content: content,
- end: function (index) {
- layer.close(index);
- }
- });
- });
- });
- function setUpdateFlag() {
- updateflag = 1;
- }
- function getXmApproval() {
- return xmApproval;
- }
- </script>
- </body>
- </html>
|