From afa3bc1e2f39f66f59ee9b15d6af16593acdc9a4 Mon Sep 17 00:00:00 2001 From: LSH Date: 星期六, 02 十二月 2023 10:38:27 +0800 Subject: [PATCH] # --- src/main/webapp/static/js/contract/contract.js | 387 +++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 288 insertions(+), 99 deletions(-) diff --git a/src/main/webapp/static/js/contract/contract.js b/src/main/webapp/static/js/contract/contract.js index c99f6e3..48362f9 100644 --- a/src/main/webapp/static/js/contract/contract.js +++ b/src/main/webapp/static/js/contract/contract.js @@ -1,19 +1,78 @@ var pageCurr; +var sign=false; layui.config({ base: baseUrl + "/static/layui/lay/modules/" -}).use(['table','laydate', 'form', 'admin'], function(){ +}).use(['table', 'laydate', 'form', 'admin','xmSelect', 'tree', 'dropdown'], function () { var table = layui.table; var $ = layui.jquery; var layer = layui.layer; var layDate = layui.laydate; var form = layui.form; var admin = layui.admin; + var dropdown = layui.dropdown; + var tree = layui.tree; + + $('#organization').html(localStorage.getItem('nickname') + ' <i class="layui-icon"></i>'); + + // 閮ㄩ棬浜哄憳 绛涢�� + dropdown.render({ + elem: '#organization' + , content: ['<div id="organizationTree" style="height: calc(100vh - 525px);border: none"></div>'].join('') + , style: 'width: 370px; height: 350px; padding: 0 15px; box-shadow: 1px 1px 30px rgb(0 0 0 / 12%);overflow: scroll;' + , ready: function () { + loadTree(); + } + }); + + // 鏍戝舰鍥� + var organizationTree; + window.loadTree = function (condition) { + var loadIndex = layer.load(2); + $.ajax({ + url: baseUrl + "/dept/user/tree/auth", + headers: {'token': localStorage.getItem('token')}, + data: { + 'condition': condition + }, + method: 'POST', + success: function (res) { + layer.close(loadIndex); + if (res.code === 200) { + organizationTree = tree.render({ + elem: '#organizationTree', + id: 'organizationTree', + onlyIconControl: true, + data: res.data, + click: function (obj) { + treeCond = { + key: obj.data.key, + val: obj.data.id + } + $('#organization').html(obj.data.title + ' <i class="layui-icon"></i>'); + $('#organizationTree').find('.ew-tree-click').removeClass('ew-tree-click'); + $(obj.elem).children('.layui-tree-entry').addClass('ew-tree-click'); + clearFormVal($('#search-box')); + tableIns.reload({ + where: {[obj.data.key]: obj.data.id}, + page: {curr: 1} + }); + } + }); + treeData = res.data; + } else if (res.code === 403) { + top.location.href = baseUrl + "/"; + } else { + layer.msg(res.msg) + } + } + }) + } // 鏁版嵁娓叉煋 tableIns = table.render({ elem: '#contract', headers: {token: localStorage.getItem('token')}, - url: baseUrl+'/contract/list/auth', + url: baseUrl + '/contract/list/auth', page: true, limit: 15, limits: [15, 30, 50, 100, 200, 500], @@ -22,18 +81,20 @@ height: 'full-120', cols: [[ {type: 'checkbox'} - ,{field: 'id', align: 'center',title: '#ID'} - ,{field: 'name', align: 'center',title: '鍚堝悓鍚嶇О'} - ,{field: 'customer', align: 'center',title: '鐢叉柟'} - ,{field: 'company', align: 'center',title: '鍏徃鍚嶇О'} - ,{field: 'status$', align: 'center',title: '鐘舵��'} - ,{field: 'createBy$', align: 'center',title: '娣诲姞浜哄憳'} - ,{field: 'createTime$', align: 'center',title: '娣诲姞鏃堕棿'} - ,{field: 'updateBy$', align: 'center',title: '淇敼浜哄憳'} - ,{field: 'updateTime$', align: 'center',title: '淇敼鏃堕棿'} - ,{field: 'memo', align: 'center',title: '澶囨敞'} + // ,{field: 'id', align: 'center',title: '#ID'} + , {field: 'serial', align: 'center', title: '鍚堝悓缂栧彿'} + , {field: 'name', align: 'center', title: '鍚堝悓鍚嶇О'} + , {field: 'customer', align: 'center', title: '鐢叉柟'} + , {field: 'company', align: 'center', title: '鍏徃鍚嶇О'} + , {field: 'status$', align: 'center', title: '鐘舵��'} + , {field: 'userId$', align: 'center', title: '娣诲姞浜哄憳'} + , {field: 'createTime$', align: 'center', title: '娣诲姞鏃堕棿'} + , {field: 'settle$', align: 'center',title: '杩涘害', style: 'color: #1890ff;cursor:pointer', event: 'more',hide: false} + , {field: 'updateBy$', align: 'center', title: '淇敼浜哄憳'} + , {field: 'updateTime$', align: 'center', title: '淇敼鏃堕棿'} + , {field: 'memo', align: 'center', title: '澶囨敞'} - ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:400} + , {fixed: 'right', title: '鎿嶄綔', align: 'center', toolbar: '#operate', width: 500} ]], request: { pageName: 'curr', @@ -50,11 +111,11 @@ response: { statusCode: 200 }, - done: function(res, curr, count) { + done: function (res, curr, count) { if (res.code === 403) { - top.location.href = baseUrl+"/"; + top.location.href = baseUrl + "/"; } - pageCurr=curr; + pageCurr = curr; limit(); } }); @@ -62,7 +123,7 @@ // 鐩戝惉鎺掑簭浜嬩欢 table.on('sort(contract)', function (obj) { var searchData = {}; - $.each($('#search-box [name]').serializeArray(), function() { + $.each($('#search-box [name]').serializeArray(), function () { searchData[this.name] = this.value; }); searchData['orderByField'] = obj.field; @@ -76,23 +137,23 @@ // 鐩戝惉澶村伐鍏锋爮浜嬩欢 table.on('toolbar(contract)', function (obj) { var checkStatus = table.checkStatus(obj.config.id).data; - switch(obj.event) { + switch (obj.event) { case 'addData': showEditModel(); break; case 'deleteData': - if (checkStatus.length === 0) { - layer.msg('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁', {icon: 2}); - return; - } - del(checkStatus.map(function (d) { - return d.id; - })); - break; + if (checkStatus.length === 0) { + layer.msg('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁', {icon: 2}); + return; + } + del(checkStatus.map(function (d) { + return d.id; + })); + break; case 'exportData': - admin.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function(){ - var titles=[]; - var fields=[]; + admin.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function () { + var titles = []; + var fields = []; obj.config.cols[0].map(function (col) { if (col.type === 'normal' && col.hide === false && col.toolbar == null) { titles.push(col.title); @@ -100,7 +161,7 @@ } }); var exportData = {}; - $.each($('#search-box [name]').serializeArray(), function() { + $.each($('#search-box [name]').serializeArray(), function () { exportData[this.name] = this.value; }); var param = { @@ -108,18 +169,18 @@ 'fields': fields }; $.ajax({ - url: baseUrl+"/contract/export/auth", + url: baseUrl + "/contract/export/auth", headers: {'token': localStorage.getItem('token')}, data: JSON.stringify(param), - dataType:'json', - contentType:'application/json;charset=UTF-8', + dataType: 'json', + contentType: 'application/json;charset=UTF-8', method: 'POST', success: function (res) { layer.closeAll(); if (res.code === 200) { - table.exportFile(titles,res.data,'xls'); + table.exportFile(titles, res.data, 'xls'); } else if (res.code === 403) { - top.location.href = baseUrl+"/"; + top.location.href = baseUrl + "/"; } else { layer.msg(res.msg, {icon: 2}) } @@ -131,31 +192,79 @@ }); // 鐩戝惉琛屽伐鍏蜂簨浠� - table.on('tool(contract)', function(obj){ + table.on('tool(contract)', function (obj) { var data = obj.data; switch (obj.event) { - case 'edit': - showEditModel(data); + case 'approval': + layer.confirm('瀹℃壒閫氳繃锛�', { + skin: 'layui-layer-admin', + shade: .1, + offset: '200px', + title: data.name + }, function (i) { + layer.close(i); + approval(data.id); + }); break; + case 'more': + top.contractByMore = data.id; + admin.popupRight({ + type: 1, + window: "top", + area: "1250px", + url: "contract_more.html", + end: function () { + // $(".layui-laypage-btn")[0].click(); + } + }) + break; + case 'edit': + if (sign){ + showEditModel(data); + break; + }else { + layer.msg('鎶辨瓑浣犳病鏉冮檺', {icon: 2}); + break + } case "del": del([data.id]); break; case "generate": - //鐢熸垚鍚堝悓 - generate(data) - break + if (sign){ + //鐢熸垚鍚堝悓 + generate(data) + break + }else { + layer.msg('鎶辨瓑浣犳病鏉冮檺', {icon: 2}); + break + } case "sales": - //鍚堝悓鏄庣粏 - sales(data); - break + if (sign){ + //鍚堝悓鏄庣粏 + sales(data); + break + }else { + layer.msg('鎶辨瓑浣犳病鏉冮檺', {icon: 2}); + break + } case "upload": - //涓婁紶鍚堝悓 - upload(data) - break + if (sign){ + //涓婁紶鍚堝悓 + upload(data) + break + }else { + layer.msg('鎶辨瓑浣犳病鏉冮檺', {icon: 2}); + break + } case "download": - //涓嬭浇鍚堝悓 - download(data) - break + if (sign){ + //涓嬭浇鍚堝悓 + download(data) + break + }else { + layer.msg('鎶辨瓑浣犳病鏉冮檺', {icon: 2}); + break + } } }); @@ -167,24 +276,27 @@ title: (mData ? '淇敼' : '娣诲姞') + '鍚堝悓', content: $('#editDialog').html(), success: function (layero, dIndex) { + let loadNameXml = loadNameXmlSel() + console.log(loadNameXml) layDateRender(mData); form.val('detail', mData); form.on('submit(editSubmit)', function (data) { + data.field.customer = loadNameXml.getValue()[0] ? loadNameXml.getValue()[0].name : null; var loadIndex = layer.load(2); $.ajax({ - url: baseUrl+"/contract/"+(mData?'update':'add')+"/auth", + url: baseUrl + "/contract/" + (mData ? 'update' : 'add') + "/auth", headers: {'token': localStorage.getItem('token')}, data: data.field, method: 'POST', success: function (res) { layer.close(loadIndex); - if (res.code === 200){ + if (res.code === 200) { layer.close(dIndex); layer.msg(res.msg, {icon: 1}); tableReload(); - } else if (res.code === 403){ - top.location.href = baseUrl+"/"; - }else { + } else if (res.code === 403) { + top.location.href = baseUrl + "/"; + } else { layer.msg(res.msg, {icon: 2}); } } @@ -231,7 +343,7 @@ a.click(); // 娓呯悊涓存椂璧勬簮 - setTimeout(function() { + setTimeout(function () { window.URL.revokeObjectURL(url); document.body.removeChild(a); }, 100); @@ -254,10 +366,10 @@ type: 2, title: '鍚堝悓鏄庣粏', maxmin: true, - area: [top.detailWidth,top.detailHeight], + area: [top.detailWidth, top.detailHeight], shadeClose: false, content: '../contractSales/contractSales.html?contractId=' + mData.id, - success: function(layero, index){ + success: function (layero, index) { } }); } @@ -265,24 +377,24 @@ //涓婁紶鍚堝悓 function upload(data) { if (data.filepath == '' || data.filepath == null) { - layer.confirm('鏄惁涓婁紶鍚堝悓?', function(){ + layer.confirm('鏄惁涓婁紶鍚堝悓?', function () { $("#uploadQuote").click() }); - }else { - layer.confirm('宸蹭笂浼犲悎鍚岋紝鏄惁缁х画瑕嗙洊涓婁紶?', function(){ + } else { + layer.confirm('宸蹭笂浼犲悎鍚岋紝鏄惁缁х画瑕嗙洊涓婁紶?', function () { $("#uploadQuote").click() }); } - $("#uploadQuote").on("change",(evt) => { + $("#uploadQuote").on("change", (evt) => { var files = evt.target.files; - if(files==null || files.length==0){ + if (files == null || files.length == 0) { alert("No files wait for import"); return; } let name = files[0].name; - let suffixArr = name.split("."), suffix = suffixArr[suffixArr.length-1]; + let suffixArr = name.split("."), suffix = suffixArr[suffixArr.length - 1]; // if(suffix!="xlsx"){ // alert("Currently only supports the import of xlsx files"); // return; @@ -300,11 +412,11 @@ contentType: false, success: function (res) { if (res.code == 200) { - layer.msg('涓婁紶鎴愬姛',{time:1000},() => { + layer.msg('涓婁紶鎴愬姛', {time: 1000}, () => { parent.location.reload() }) - }else{ - layer.msg(res.msg,{time:1000},() => { + } else { + layer.msg(res.msg, {time: 1000}, () => { parent.location.reload() }) } @@ -316,34 +428,32 @@ //涓嬭浇鍚堝悓 function download(data) { $.ajax({ - url: baseUrl+"/contract/download/auth", + url: baseUrl + "/contract/download/auth", headers: {'token': localStorage.getItem('token')}, data: data, method: 'GET', - xhrFields: { - responseType: "blob" // 璁剧疆鍝嶅簲绫诲瀷涓轰簩杩涘埗鏁版嵁 - }, success: function (res) { - // 鍒涘缓涓�涓复鏃剁殑涓嬭浇閾炬帴 - const url = window.URL.createObjectURL(res); - // 鍒涘缓涓�涓殣钘忕殑 <a> 鍏冪礌骞惰缃笅杞介摼鎺� - const a = document.createElement("a"); - a.style.display = "none"; - a.href = url; - - let list = data.filepath.split(".") - let suffix = "." + list[list.length - 1]//鑾峰彇鍚庣紑鍚� - a.download = data.name + suffix; // 鎸囧畾涓嬭浇鐨勬枃浠跺悕 - document.body.appendChild(a); - - // 瑙﹀彂鐐瑰嚮浜嬩欢浠ュ紑濮嬩笅杞� - a.click(); - - // 娓呯悊涓存椂璧勬簮 - setTimeout(function() { - window.URL.revokeObjectURL(url); - document.body.removeChild(a); - }, 100); + location.href = res.data + // // 鍒涘缓涓�涓复鏃剁殑涓嬭浇閾炬帴 + // const url = window.URL.createObjectURL(res); + // // 鍒涘缓涓�涓殣钘忕殑 <a> 鍏冪礌骞惰缃笅杞介摼鎺� + // const a = document.createElement("a"); + // a.style.display = "none"; + // a.href = url; + // + // let list = data.filepath.split(".") + // let suffix = "." + list[list.length - 1]//鑾峰彇鍚庣紑鍚� + // a.download = data.name + suffix; // 鎸囧畾涓嬭浇鐨勬枃浠跺悕 + // document.body.appendChild(a); + // + // // 瑙﹀彂鐐瑰嚮浜嬩欢浠ュ紑濮嬩笅杞� + // a.click(); + // + // // 娓呯悊涓存椂璧勬簮 + // setTimeout(function () { + // window.URL.revokeObjectURL(url); + // document.body.removeChild(a); + // }, 100); } }); } @@ -357,17 +467,17 @@ layer.close(i); var loadIndex = layer.load(2); $.ajax({ - url: baseUrl+"/contract/delete/auth", + url: baseUrl + "/contract/delete/auth", headers: {'token': localStorage.getItem('token')}, data: {ids: ids}, method: 'POST', success: function (res) { layer.close(loadIndex); - if (res.code === 200){ + if (res.code === 200) { layer.msg(res.msg, {icon: 1}); tableReload(); - } else if (res.code === 403){ - top.location.href = baseUrl+"/"; + } else if (res.code === 403) { + top.location.href = baseUrl + "/"; } else { layer.msg(res.msg, {icon: 2}); } @@ -394,26 +504,105 @@ setTimeout(function () { layDate.render({ elem: '.layui-laydate-range' - ,type: 'datetime' - ,range: true + , type: 'datetime' + , range: true }); layDate.render({ elem: '#createTime\\$', type: 'datetime', - value: data!==undefined?data['createTime\\$']:null + value: data !== undefined ? data['createTime\\$'] : null }); layDate.render({ elem: '#updateTime\\$', type: 'datetime', - value: data!==undefined?data['updateTime\\$']:null + value: data !== undefined ? data['updateTime\\$'] : null }); }, 300); } + layDateRender(); + function approval(contractId, plannerId, dIdx) { + let loadIndex = layer.load(2); + $.ajax({ + url: baseUrl+"/contract/approval/auth", + headers: {'token': localStorage.getItem('token')}, + data: { + contractId: contractId, + plannerId: plannerId + }, + method: 'POST', + success: function (res) { + if (dIdx) { + layer.close(dIdx); + } + layer.close(loadIndex); + if (res.code === 200){ + layer.msg(res.msg, {icon: 1}); + tableReload(); + } else if (res.code === 403){ + top.location.href = baseUrl+"/"; + } else { + layer.msg(res.msg, {icon: 2}); + } + } + }) + } + + window.loadNameXmlSel = function () { + return xmSelect.render({ + el: '#nameXmlSel', + autoRow: true, + filterable: true, + remoteSearch: true, + clickClose: true, + radio: true, + remoteMethod: function (val, cb, show) { + $.ajax({ + url: baseUrl + "/cstmr/all/get/kv", + headers: {'token': localStorage.getItem('token')}, + data: { + condition: val + }, + method: 'POST', + success: function (res) { + if (res.code === 200) { + cb(res.data) + } else { + cb([]); + layer.msg(res.msg, {icon: 2}); + } + } + }); + }, + }); + } + f(); }); +function f() { + let token = localStorage.getItem("token"); + layui.jquery.ajax({ + url: baseUrl + "/dashboard/popup/auth", + data:{token : token}, + method: 'GET', + success: function (res) { + if (res.code === 200) { + if (res.msg === "true"){ + sign=true; + }else { + + } + console.log(sign) + // showPopupGenerate(res.msg) + // showPopupDel(res.msg) + // showPopupEdit(res.msg) + } + } + }) +} + // 鍏抽棴鍔ㄤ綔 $(document).on('click','#data-detail-close', function () { parent.layer.closeAll(); -- Gitblit v1.9.1