diff --git a/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseAdd.js b/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseAdd.js index f879ec5446141f3d26d16b315b3ed58b389abccb..ba7202efc454811f6a7a9cc9725d975646dc0f5d 100644 --- a/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseAdd.js +++ b/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseAdd.js @@ -13,74 +13,95 @@ layui.config({ var $ = layui.$, form = layui.form; var serviceClassName = sysServiceMation["assetArticlesUse"]["key"]; - var rowNum = 1; //表格的序号 var typeHtml = ""; - var usetableTemplate = $("#usetableTemplate").html(); var selOption = getFileContent('tpl/template/select-option.tpl'); skyeyeEnclosure.init('enclosureUpload'); - // 获取当前登录员工信息 systemCommonUtil.getSysCurrentLoginUserMation(function (data) { - $("#useTitle").html("用品领用申请单-" + getYMDFormatDate() + '-' + data.bean.userName); + $("#title").html("用品领用申请单-" + getYMDFormatDate() + '-' + data.bean.userName); $("#useName").html(data.bean.userName); - initTypeHtml(); }); - function initTypeHtml() { - // 用品类别 - sysDictDataUtil.queryDictDataListByDictTypeCode(sysDictData["admAssetArticlesType"]["key"], function (data) { - typeHtml = getDataUseHandlebars(selOption, data); - }); + // 用品类别 + sysDictDataUtil.queryDictDataListByDictTypeCode(sysDictData["admAssetArticlesType"]["key"], function (data) { + typeHtml = getDataUseHandlebars(selOption, data); + }); - matchingLanguage(); - //渲染 - form.render(); - //类型加载变化事件 - form.on('select(selectTypeProperty)', function(data) { - var thisRowNum = data.elem.id.replace("typeId", ""); - var thisRowValue = data.value; - if (!isNull(thisRowValue) && thisRowValue != '请选择') { - if(inPointArray(thisRowValue, assetArticles)) { - //类型对应的用品存在js对象中 - var list = getListPointArray(thisRowValue, assetArticles); - resetAssetList(thisRowNum, list); //重置选择行的用品列表 - } else { - //类型对应的用品不存在js对象中 - AjaxPostUtil.request({url: flowableBasePath + "assetarticles018", params: {typeId: thisRowValue}, type: 'json', method: 'GET', callback: function(json) { - assetArticles.push({ - id: thisRowValue, - list: json.rows - }); - resetAssetList(thisRowNum, json.rows); //重置选择行的用品列表 - }}); - } - } - }); + initTableChooseUtil.initTable({ + id: "articlesList", + cols: [ + {id: 'typeId', title: '类别', formType: 'select', width: '150', verify: 'required', layFilter: 'selectTypeProperty', modelHtml: typeHtml}, + {id: 'articleId', title: '用品', formType: 'select', width: '150', verify: 'required', layFilter: 'selectAssetarProperty'}, + {id: 'specifications', title: '规格(单位)', formType: 'detail', width: '80'}, + {id: 'residualNum', title: '库存', formType: 'detail', width: '80'}, + {id: 'applyUseNum', title: '领用数量', formType: 'input', width: '80', verify: 'required|number', value: '1'}, + {id: 'remark', title: '备注', formType: 'input', width: '100'} + ], + deleteRowCallback: function (trcusid) { + }, + addRowCallback: function (trcusid) { + }, + form: form, + minData: 1 + }); - //商品加载变化事件 - form.on('select(selectAssetarProperty)', function(data) { - var thisRowNum = data.elem.id.replace("assetarId", ""); - var thisRowValue = data.value; - var thisRowTypeChooseId = $("#typeId" + thisRowNum).val(); - if (!isNull(thisRowValue) && thisRowValue != '请选择') { - var list = getListPointArray(thisRowTypeChooseId, assetArticles); - $.each(list, function(i, item) { - if(item.id === thisRowValue) { - $("#specificationsName" + thisRowNum).html(item.specificationsName); - $("#residualNum" + thisRowNum).html(item.residualNum); - return false; - } - }); + matchingLanguage(); + form.render(); + + // 类型加载变化事件 + form.on('select(selectTypeProperty)', function(data) { + var thisRowNum = data.elem.id.replace("typeId", ""); + var thisRowValue = data.value; + if (!isNull(thisRowValue) && thisRowValue != '请选择') { + if (judgeInPoingArr(assetArticles, 'id', thisRowValue)) { + // 类型对应的用品存在js对象中 + var list = getInPoingArr(assetArticles, 'id', thisRowValue, 'list'); + resetAssetList(thisRowNum, list); //重置选择行的用品列表 } else { - $("#specificationsName" + thisRowNum).html(""); //重置规格为空 - $("#residualNum" + thisRowNum).html(""); //重置库存为空 + // 类型对应的用品不存在js对象中 + AjaxPostUtil.request({url: flowableBasePath + "assetarticles018", params: {typeId: thisRowValue}, type: 'json', method: 'GET', callback: function (json) { + assetArticles.push({ + id: thisRowValue, + list: json.rows + }); + resetAssetList(thisRowNum, json.rows); + }}); } + } + }); + + // 根据类型重置用户列表 + function resetAssetList(thisRowNum, list) { + var sHtml = getDataUseHandlebars(selOption, { + rows: list }); - // 初始化一行数据 - addRow(); + $("#articleId" + thisRowNum).html(sHtml); + $("#specifications" + thisRowNum).html(""); + $("#residualNum" + thisRowNum).html(""); + form.render('select'); } + // 商品加载变化事件 + form.on('select(selectAssetarProperty)', function(data) { + var thisRowNum = data.elem.id.replace("articleId", ""); + var thisRowValue = data.value; + var thisRowTypeChooseId = $("#typeId" + thisRowNum).val(); + if (!isNull(thisRowValue) && thisRowValue != '请选择') { + var list = getInPoingArr(assetArticles, 'id', thisRowTypeChooseId, 'list'); + $.each(list, function (i, item) { + if (item.id === thisRowValue) { + $("#specifications" + thisRowNum).html(item.specificationsName); + $("#residualNum" + thisRowNum).html(item.residualNum); + return false; + } + }); + } else { + $("#specifications" + thisRowNum).html(""); + $("#residualNum" + thisRowNum).html(""); + } + }); + // 保存为草稿 form.on('submit(formAddBean)', function(data) { if(winui.verifyForm(data.elem)) { @@ -100,54 +121,45 @@ layui.config({ }); function saveData(subType, approvalId) { - // 获取已选用品数据 - var rowTr = $("#useTable tr"); - if(rowTr.length == 0) { - winui.window.msg('请选择需要领用的用品~', {icon: 2, time: 2000}); + var result = initTableChooseUtil.getDataList('articlesList'); + if (!result.checkResult) { return false; } - var tableData = new Array(); - var noError = false; //循环遍历表格数据时,是否有其他错误信息 - $.each(rowTr, function(i, item) { - var rowNum = $(item).attr("trcusid").replace("tr", ""); - var residualNum = parseInt($("#residualNum" + rowNum).html()); - if(parseInt($("#useNum" + rowNum).val()) == 0) { - $("#useNum" + rowNum).addClass("layui-form-danger"); - $("#useNum" + rowNum).focus(); + var noError = false; + var tableData = []; + $.each(result.dataList, function (i, item) { + var rowNum = item["trcusid"].replace("tr", ""); + if (parseInt(item.applyUseNum) == 0) { + $("#applyUseNum" + rowNum).addClass("layui-form-danger"); + $("#applyUseNum" + rowNum).focus(); winui.window.msg('领用数量不能为0', {icon: 2, time: 2000}); noError = true; return false; } - if(parseInt($("#useNum" + rowNum).val()) > residualNum) { - $("#useNum" + rowNum).addClass("layui-form-danger"); - $("#useNum" + rowNum).focus(); + if (parseInt(item.applyUseNum) > parseInt(item.residualNum)) { + $("#applyUseNum" + rowNum).addClass("layui-form-danger"); + $("#applyUseNum" + rowNum).focus(); winui.window.msg('领用数量不能超过库存数量', {icon: 2, time: 2000}); noError = true; return false; } - if(inTableDataArrayByAssetarId($("#assetarId" + rowNum).val(), tableData)){ + if (judgeInPoingArr(tableData, 'articleId', $("#assetarId" + rowNum).val())) { winui.window.msg('领用单存在相同的用品', {icon: 2, time: 2000}); noError = true; return false; } - var row = { - typeId: $("#typeId" + rowNum).val(), - assetarId: $("#assetarId" + rowNum).val(), - useNum: $("#useNum" + rowNum).val(), - remark: $("#remark" + rowNum).val() - }; - tableData.push(row); + tableData.push(item); }); - if(noError) { + if (noError) { return false; } var params = { - title: $("#useTitle").html(), + title: $("#title").html(), remark: $("#remark").val(), - assetArticlesStr: JSON.stringify(tableData), - enclosureInfo: skyeyeEnclosure.getEnclosureIdsByBoxId('enclosureUpload'), - subType: subType, // 表单类型 1.保存草稿 2.提交审批 + assetArticles: JSON.stringify(tableData), + enclosureInfo: JSON.stringify({enclosureInfo: skyeyeEnclosure.getEnclosureIdsByBoxId('enclosureUpload')}), + formSubType: subType, approvalId: approvalId }; AjaxPostUtil.request({url: flowableBasePath + "writeAssetArticlesApplyUse", params: params, type: 'json', method: "POST", callback: function(json) { @@ -156,95 +168,6 @@ layui.config({ }}); } - //判断选中的用品是否也在数组中 - function inTableDataArrayByAssetarId(str, array) { - var isIn = false; - $.each(array, function(i, item) { - if(item.assetarId === str) { - isIn = true; - return false; - } - }); - return isIn; - } - - //新增行 - $("body").on("click", "#addRow", function() { - addRow(); - }); - - //删除行 - $("body").on("click", "#deleteRow", function() { - deleteRow(); - }); - - //新增行 - function addRow() { - var par = { - id: "row" + rowNum.toString(), //checkbox的id - trId: "tr" + rowNum.toString(), //行的id - typeId: "typeId" + rowNum.toString(), //类型id - assetarId: "assetarId" + rowNum.toString(), //用品id - specificationsName: "specificationsName" + rowNum.toString(), //规格id - residualNum: "residualNum" + rowNum.toString(), //库存id - useNum: "useNum" + rowNum.toString(), //领用数量id - remark: "remark" + rowNum.toString() //备注id - }; - $("#useTable").append(getDataUseHandlebars(usetableTemplate, par)); - //赋值给用品类别 - $("#" + "typeId" + rowNum.toString()).html(typeHtml); - form.render('select'); - form.render('checkbox'); - rowNum++; - } - - //删除行 - function deleteRow() { - var checkRow = $("#useTable input[type='checkbox'][name='tableCheckRow']:checked"); - if(checkRow.length > 0) { - $.each(checkRow, function(i, item) { - $(item).parent().parent().remove(); - }); - } else { - winui.window.msg('请选择要删除的行', {icon: 2, time: 2000}); - } - } - - //根据类型重置用户列表 - function resetAssetList(thisRowNum, list) { - var sHtml = getDataUseHandlebars(selOption, { - rows: list - }); - $("#assetarId" + thisRowNum).html(sHtml); //重置商品列表下拉框 - $("#specificationsName" + thisRowNum).html(""); //重置规格为空 - $("#residualNum" + thisRowNum).html(""); //重置库存为空 - form.render('select'); - } - - //判断是否在数组中 - function inPointArray(str, array) { - var isIn = false; - $.each(array, function(i, item) { - if(item.id === str) { - isIn = true; - return false; - } - }); - return isIn; - } - - //获取指定key对应的集合 - function getListPointArray(str, array) { - var isList = []; - $.each(array, function(i, item) { - if(item.id === str) { - $.extend(true, isList, item.list); - return false; - } - }); - return isList; - } - $("body").on("click", "#cancle", function() { parent.layer.close(index); }); diff --git a/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseDetails.js b/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseDetails.js index b6450f7748d893ddb8994f816021fa6186a2ee2d..aa6857fc4f9135f7b452b71ef6c4ee3eddcde34d 100644 --- a/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseDetails.js +++ b/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseDetails.js @@ -4,21 +4,18 @@ layui.config({ version: skyeyeVersion }).extend({ window: 'js/winui.window' -}).define(['window', 'jquery', 'winui'], function (exports) { +}).define(['window', 'jquery', 'winui', 'form'], function (exports) { winui.renderColor(); - layui.use(['form'], function (form) { - var index = parent.layer.getFrameIndex(window.name); - var $ = layui.$; - - AjaxPostUtil.request({url: flowableBasePath + "assetarticles020", params: {rowId: parent.rowId}, type: 'json', callback: function (json) { - json.bean.stateName = activitiUtil.showStateName2(json.bean.state, 1); + var index = parent.layer.getFrameIndex(window.name); + var $ = layui.$, + form = layui.form; - $("#showForm").html(getDataUseHandlebars($("#useTemplate").html(), json)); + AjaxPostUtil.request({url: flowableBasePath + "queryAssetArticlesApplyUseById", params: {id: parent.rowId}, type: 'json', method: 'GET', callback: function (json) { + $("#showForm").html(getDataUseHandlebars($("#useTemplate").html(), json)); - // 附件回显 - skyeyeEnclosure.showDetails({"enclosureUploadBtn": json.bean.enclosureInfo}); - matchingLanguage(); - }}); - - }); + // 附件回显 + skyeyeEnclosure.showDetails({"enclosureUploadBtn": json.bean.enclosureInfo}); + matchingLanguage(); + form.render(); + }}); }); \ No newline at end of file diff --git a/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseEdit.js b/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseEdit.js index 6cabcef71e25678bffaed660034e3ef74218f435..5aee21b0a8e1ac5103540a2556660392ad2c0050 100644 --- a/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseEdit.js +++ b/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseEdit.js @@ -13,90 +13,125 @@ layui.config({ var $ = layui.$, form = layui.form; var serviceClassName = sysServiceMation["assetArticlesUse"]["key"]; - var rowNum = 1; //表格的序号 var typeHtml = ""; - - var usetableTemplate = $("#usetableTemplate").html(); var selOption = getFileContent('tpl/template/select-option.tpl'); - var sTableData = ""; - - AjaxPostUtil.request({url: flowableBasePath + "assetarticles021", params: {rowId: parent.rowId}, type: 'json', method: "POST", callback: function(json) { - $("#useTitle").html(json.bean.title); - $("#useName").html(json.bean.userName); + AjaxPostUtil.request({url: flowableBasePath + "queryAssetArticlesApplyUseById", params: {id: parent.rowId}, type: 'json', method: "GET", callback: function(json) { + $("#title").html(json.bean.title); + $("#useName").html(json.bean.createName); $("#remark").val(json.bean.remark); // 附件回显 skyeyeEnclosure.initTypeISData({'enclosureUpload': json.bean.enclosureInfo}); - if(json.bean.state == '1'){ - $(".typeTwo").removeClass("layui-hide"); - } else { - $(".typeOne").removeClass("layui-hide"); - } - sTableData = json.bean.goods; - initTypeHtml(); - matchingLanguage(); - }}); - - function initTypeHtml() { // 用品类别 sysDictDataUtil.queryDictDataListByDictTypeCode(sysDictData["admAssetArticlesType"]["key"], function (data) { typeHtml = getDataUseHandlebars(selOption, data); }); + initTable(); + + initTableChooseUtil.deleteAllRow('articlesList'); + $.each(json.bean.assetArticles, function(i, item) { + var list = findArticlesByTypeId(item.assetArticles.typeId); + var params = { + "typeId": { + "value": item.assetArticles.typeId + }, + "articleId": { + "html": getDataUseHandlebars(selOption, {rows: list}), + "value": item.articleId + }, + "specifications": item.assetArticles.specifications, + "residualNum": item.assetArticles.residualNum, + "applyUseNum": item.applyUseNum, + "remark": item.remark + }; + initTableChooseUtil.resetData('articlesList', params); + }); + + matchingLanguage(); form.render(); - //类型加载变化事件 - form.on('select(selectTypeProperty)', function(data) { - var thisRowNum = data.elem.id.replace("typeId", ""); - var thisRowValue = data.value; - if (!isNull(thisRowValue) && thisRowValue != '请选择') { - if(inPointArray(thisRowValue, assetArticles)) { - //类型对应的用品存在js对象中 - var list = getListPointArray(thisRowValue, assetArticles); - resetAssetList(thisRowNum, list); //重置选择行的用品列表 - } else { - //类型对应的用品不存在js对象中 - AjaxPostUtil.request({url: flowableBasePath + "assetarticles018", params: {typeId: thisRowValue}, type: 'json', method: 'GET', callback: function(json) { - assetArticles.push({ - id: thisRowValue, - list: json.rows - }); - resetAssetList(thisRowNum, json.rows); //重置选择行的用品列表 - }}); - } - } + }}); + + function initTable() { + initTableChooseUtil.initTable({ + id: "articlesList", + cols: [ + {id: 'typeId', title: '类别', formType: 'select', width: '150', verify: 'required', layFilter: 'selectTypeProperty', modelHtml: typeHtml}, + {id: 'articleId', title: '用品', formType: 'select', width: '150', verify: 'required', layFilter: 'selectAssetarProperty'}, + {id: 'specifications', title: '规格(单位)', formType: 'detail', width: '80'}, + {id: 'residualNum', title: '库存', formType: 'detail', width: '80'}, + {id: 'applyUseNum', title: '领用数量', formType: 'input', width: '80', verify: 'required|number', value: '1'}, + {id: 'remark', title: '备注', formType: 'input', width: '100'} + ], + deleteRowCallback: function (trcusid) { + }, + addRowCallback: function (trcusid) { + }, + form: form, + minData: 1 }); + } - //商品加载变化事件 - form.on('select(selectAssetarProperty)', function(data) { - var thisRowNum = data.elem.id.replace("assetarId", ""); - var thisRowValue = data.value; - var thisRowTypeChooseId = $("#typeId" + thisRowNum).val(); - if (!isNull(thisRowValue) && thisRowValue != '请选择') { - var list = getListPointArray(thisRowTypeChooseId, assetArticles); - $.each(list, function(i, item) { - if(item.id === thisRowValue) { - $("#specificationsName" + thisRowNum).html(item.specificationsName); - $("#residualNum" + thisRowNum).html(item.residualNum); - return false; - } + // 类型加载变化事件 + form.on('select(selectTypeProperty)', function(data) { + var thisRowNum = data.elem.id.replace("typeId", ""); + var thisRowValue = data.value; + if (!isNull(thisRowValue) && thisRowValue != '请选择') { + var list = findArticlesByTypeId(thisRowValue); + resetAssetList(thisRowNum, list); + } + }); + + function findArticlesByTypeId(typeId) { + var list; + if (judgeInPoingArr(assetArticles, 'id', typeId)) { + // 类型对应的用品存在js对象中 + list = getInPoingArr(assetArticles, 'id', typeId, 'list'); + } else { + // 类型对应的用品不存在js对象中 + AjaxPostUtil.request({url: flowableBasePath + "assetarticles018", params: {typeId: typeId}, type: 'json', method: 'GET', callback: function (json) { + assetArticles.push({ + id: typeId, + list: json.rows }); - } else { - $("#specificationsName" + thisRowNum).html(""); //重置规格为空 - $("#residualNum" + thisRowNum).html(""); //重置库存为空 - } - }); - //加载表格数据 - initTableAssetList(); + list = json.rows; + }, async: false}); + } + return list; } - //加载表格数据 - function initTableAssetList() { - $.each(sTableData, function(i, item) { - addDataRow(item); + // 根据类型重置用户列表 + function resetAssetList(thisRowNum, list) { + var sHtml = getDataUseHandlebars(selOption, { + rows: list }); + $("#articleId" + thisRowNum).html(sHtml); + $("#specifications" + thisRowNum).html(""); + $("#residualNum" + thisRowNum).html(""); + form.render('select'); } + // 商品加载变化事件 + form.on('select(selectAssetarProperty)', function(data) { + var thisRowNum = data.elem.id.replace("articleId", ""); + var thisRowValue = data.value; + var thisRowTypeChooseId = $("#typeId" + thisRowNum).val(); + if (!isNull(thisRowValue) && thisRowValue != '请选择') { + var list = getInPoingArr(assetArticles, 'id', thisRowTypeChooseId, 'list'); + $.each(list, function (i, item) { + if (item.id === thisRowValue) { + $("#specifications" + thisRowNum).html(item.specificationsName); + $("#residualNum" + thisRowNum).html(item.residualNum); + return false; + } + }); + } else { + $("#specifications" + thisRowNum).html(""); + $("#residualNum" + thisRowNum).html(""); + } + }); + // 保存为草稿 form.on('submit(formEditBean)', function(data) { if(winui.verifyForm(data.elem)) { @@ -115,63 +150,47 @@ layui.config({ return false; }); - // 工作流中保存 - form.on('submit(subBean)', function(data) { - if(winui.verifyForm(data.elem)) { - saveData('3', ""); - } - return false; - }); - function saveData(subType, approvalId) { - // 获取已选用品数据 - var rowTr = $("#useTable tr"); - if(rowTr.length == 0) { - winui.window.msg('请选择需要领用的用品~', {icon: 2, time: 2000}); + var result = initTableChooseUtil.getDataList('articlesList'); + if (!result.checkResult) { return false; } - var tableData = new Array(); - var noError = false; //循环遍历表格数据时,是否有其他错误信息 - $.each(rowTr, function(i, item) { - var rowNum = $(item).attr("trcusid").replace("tr", ""); - var residualNum = parseInt($("#residualNum" + rowNum).html()); - if(parseInt($("#useNum" + rowNum).val()) == 0) { - $("#useNum" + rowNum).addClass("layui-form-danger"); - $("#useNum" + rowNum).focus(); + var noError = false; + var tableData = []; + $.each(result.dataList, function (i, item) { + var rowNum = item["trcusid"].replace("tr", ""); + if (parseInt(item.applyUseNum) == 0) { + $("#applyUseNum" + rowNum).addClass("layui-form-danger"); + $("#applyUseNum" + rowNum).focus(); winui.window.msg('领用数量不能为0', {icon: 2, time: 2000}); noError = true; return false; } - if(parseInt($("#useNum" + rowNum).val()) > residualNum) { - $("#useNum" + rowNum).addClass("layui-form-danger"); - $("#useNum" + rowNum).focus(); + if (parseInt(item.applyUseNum) > parseInt(item.residualNum)) { + $("#applyUseNum" + rowNum).addClass("layui-form-danger"); + $("#applyUseNum" + rowNum).focus(); winui.window.msg('领用数量不能超过库存数量', {icon: 2, time: 2000}); noError = true; return false; } - if(inTableDataArrayByAssetarId($("#assetarId" + rowNum).val(), tableData)){ + if (judgeInPoingArr(tableData, 'articleId', $("#assetarId" + rowNum).val())) { winui.window.msg('领用单存在相同的用品', {icon: 2, time: 2000}); noError = true; return false; } - var row = { - typeId: $("#typeId" + rowNum).val(), - assetarId: $("#assetarId" + rowNum).val(), - useNum: $("#useNum" + rowNum).val(), - remark: $("#remark" + rowNum).val() - }; - tableData.push(row); + tableData.push(item); }); - if(noError) { + if (noError) { return false; } var params = { + id: parent.rowId, + title: $("#title").html(), remark: $("#remark").val(), - assetArticlesStr: JSON.stringify(tableData), - rowId: parent.rowId, - enclosureInfo: skyeyeEnclosure.getEnclosureIdsByBoxId('enclosureUpload'), - subType: subType, // 1:保存为草稿 2.提交到工作流 3.在工作流中编辑 + assetArticles: JSON.stringify(tableData), + enclosureInfo: JSON.stringify({enclosureInfo: skyeyeEnclosure.getEnclosureIdsByBoxId('enclosureUpload')}), + formSubType: subType, approvalId: approvalId, }; AjaxPostUtil.request({url: flowableBasePath + "writeAssetArticlesApplyUse", params: params, type: 'json', method: 'POST', callback: function(json) { @@ -180,150 +199,6 @@ layui.config({ }}); } - // 判断选中的用品是否也在数组中 - function inTableDataArrayByAssetarId(str, array) { - var isIn = false; - $.each(array, function(i, item) { - if(item.assetarId === str) { - isIn = true; - return false; - } - }); - return isIn; - } - - //新增行 - $("body").on("click", "#addRow", function() { - addRow(); - }); - - //删除行 - $("body").on("click", "#deleteRow", function() { - deleteRow(); - }); - - //加载数据行行 - function addDataRow(item) { - var thisRowNum = rowNum.toString(); - var par = { - id: "row" + thisRowNum, //checkbox的id - trId: "tr" + thisRowNum, //行的id - typeId: "typeId" + thisRowNum, //类型id - assetarId: "assetarId" + thisRowNum, //用品id - specificationsName: "specificationsName" + thisRowNum, //规格id - residualNum: "residualNum" + thisRowNum, //库存id - useNum: "useNum" + thisRowNum, //领用数量id - remark: "remark" + thisRowNum //备注id - }; - $("#useTable").append(getDataUseHandlebars(usetableTemplate, par)); - - //赋值给用品类别 - $("#" + "typeId" + thisRowNum).html(typeHtml); - - //数据回显 - $("#typeId" + thisRowNum).val(item.typeId); - $("#specificationsName" + thisRowNum).html(item.specificationsName); - $("#remark" + thisRowNum).val(item.remark); - $("#residualNum" + thisRowNum).html(item.residualNum); - $("#useNum" + thisRowNum).val(item.applyUseNum); - var thisRowValue = item.typeId; - if (!isNull(thisRowValue) && thisRowValue != '请选择') { - if(inPointArray(thisRowValue, assetArticles)) { - //类型对应的用品存在js对象中 - var list = getListPointArray(thisRowValue, assetArticles); - //重置选择行的用品列表 - var sHtml = getDataUseHandlebars(selOption, {rows: list}); - $("#assetarId" + thisRowNum).html(sHtml); //重置商品列表下拉框 - $("#assetarId" + thisRowNum).val(item.articleId); - form.render('select'); - } else { - //类型对应的用品不存在js对象中 - AjaxPostUtil.request({url: flowableBasePath + "assetarticles018", params: {typeId: thisRowValue}, type: 'json', method: 'GET', callback: function(json) { - assetArticles.push({ - id: thisRowValue, - list: json.rows - }); - //重置选择行的用品列表 - var sHtml = getDataUseHandlebars(selOption, json); - $("#assetarId" + thisRowNum).html(sHtml); //重置商品列表下拉框 - $("#assetarId" + thisRowNum).val(item.articleId); - form.render('select'); - }, async: false}); - } - } - - form.render('select'); - form.render('checkbox'); - rowNum++; - } - - //新增行 - function addRow() { - var par = { - id: "row" + rowNum.toString(), //checkbox的id - trId: "tr" + rowNum.toString(), //行的id - typeId: "typeId" + rowNum.toString(), //类型id - assetarId: "assetarId" + rowNum.toString(), //用品id - specificationsName: "specificationsName" + rowNum.toString(), //规格id - residualNum: "residualNum" + rowNum.toString(), //库存id - useNum: "useNum" + rowNum.toString(), //领用数量id - remark: "remark" + rowNum.toString() //备注id - }; - $("#useTable").append(getDataUseHandlebars(usetableTemplate, par)); - //赋值给用品类别 - $("#" + "typeId" + rowNum.toString()).html(typeHtml); - form.render('select'); - form.render('checkbox'); - rowNum++; - } - - //删除行 - function deleteRow() { - var checkRow = $("#useTable input[type='checkbox'][name='tableCheckRow']:checked"); - if(checkRow.length > 0) { - $.each(checkRow, function(i, item) { - $(item).parent().parent().remove(); - }); - } else { - winui.window.msg('请选择要删除的行', {icon: 2, time: 2000}); - } - } - - //根据类型重置用户列表 - function resetAssetList(thisRowNum, list) { - var sHtml = getDataUseHandlebars(selOption, { - rows: list - }); - $("#assetarId" + thisRowNum).html(sHtml); //重置商品列表下拉框 - $("#specificationsName" + thisRowNum).html(""); //重置规格为空 - $("#residualNum" + thisRowNum).html(""); //重置库存为空 - form.render('select'); - } - - //判断是否在数组中 - function inPointArray(str, array) { - var isIn = false; - $.each(array, function(i, item) { - if(item.id === str) { - isIn = true; - return false; - } - }); - return isIn; - } - - //获取指定key对应的集合 - function getListPointArray(str, array) { - var isList = []; - $.each(array, function(i, item) { - if(item.id === str) { - $.extend(true, isList, item.list); - return false; - } - }); - return isList; - } - $("body").on("click", "#cancle", function() { parent.layer.close(index); }); diff --git a/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseList.js b/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseList.js index 7ae25e0883ea6c22a005b096d06fdfb90567bcd9..c2230af1a331cfee668c34e7729c3ea74f52393f 100644 --- a/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseList.js +++ b/admin-assistant/src/main/resources/template/js/assetArticlesUse/assetArticlesUseList.js @@ -5,21 +5,16 @@ layui.config({ version: skyeyeVersion }).extend({ window: 'js/winui.window' -}).define(['window', 'table', 'jquery', 'winui', 'form', 'laydate'], function (exports) { +}).define(['window', 'table', 'jquery', 'winui', 'form'], function (exports) { winui.renderColor(); var $ = layui.$, form = layui.form, - laydate = layui.laydate, table = layui.table; var serviceClassName = sysServiceMation["assetArticlesUse"]["key"]; - // 新增用品领用 authBtn('1596957289917'); - // '用品领用'页面的选取时间段表格 - laydate.render({elem: '#createTime', range: '~'}); - - // 展示用品领用列表 + // 用品领用列表 table.render({ id: 'lingyongTable', elem: '#lingyongTable', @@ -33,44 +28,49 @@ layui.config({ cols: [[ { title: systemLanguage["com.skyeye.serialNumber"][languageType], type: 'numbers' }, { field: 'title', title: '标题', width: 300, templet: function (d) { - return '' + d.title + ''; + return '' + d.title + ''; }}, - { field: 'oddNum', title: '单号', width: 200, align: 'center' }, + { field: 'oddNumber', title: '单号', width: 200, align: 'center' }, { field: 'processInstanceId', title: '流程ID', width: 80, align: 'center', templet: function (d) { - return '' + d.processInstanceId + ''; + return '' + d.processInstanceId + ''; }}, { field: 'state', title: '状态', width: 90, align: 'center', templet: function (d) { return activitiUtil.showStateName2(d.state, 1); }}, + { field: 'createName', title: systemLanguage["com.skyeye.createName"][languageType], width: 120 }, { field: 'createTime', title: systemLanguage["com.skyeye.createTime"][languageType], align: 'center', width: 150 }, - { title: systemLanguage["com.skyeye.operation"][languageType], fixed: 'right', align: 'center', width: 257, toolbar: '#lingyongTableBar'} + { field: 'lastUpdateName', title: systemLanguage["com.skyeye.lastUpdateName"][languageType], align: 'left', width: 120 }, + { field: 'lastUpdateTime', title: systemLanguage["com.skyeye.lastUpdateTime"][languageType], align: 'center', width: 150 }, + { title: systemLanguage["com.skyeye.operation"][languageType], fixed: 'right', align: 'center', width: 257, toolbar: '#lingyongTableBar' } ]], done: function(json) { matchingLanguage(); + initTableSearchUtil.initAdvancedSearch(this, json.searchFilter, form, "请输入单号,标题", function () { + table.reloadData("lingyongTable", {page: {curr: 1}, where: getTableParams()}); + }); } }); - // 用品领用的操作事件 table.on('tool(lingyongTable)', function (obj) { var data = obj.data; var layEvent = obj.event; - if (layEvent === 'lingyongDedails') { //领用详情 - lingyongDedails(data); + if (layEvent === 'details') { //领用详情 + details(data); } else if (layEvent === 'edit') { //编辑领用申请 - useedit(data); + edit(data); } else if (layEvent === 'subApproval') { //提交审批 subApproval(data); } else if (layEvent === 'cancellation') {//领用作废 cancellation(data); - } else if (layEvent === 'lingyongProcessDetails') {//领用流程详情 + } else if (layEvent === 'processDetails') {//领用流程详情 activitiUtil.activitiDetails(data); } else if (layEvent === 'revoke') { //撤销领用申请 revoke(data); } }); - // 添加用品领用 - $("body").on("click", "#addUseBean", function() { + // 添加 + $("body").on("click", "#addBean", function() { _openNewWindows({ url: "../../tpl/assetArticlesUse/assetArticlesUseAdd.html", title: "添加用品领用申请", @@ -78,24 +78,24 @@ layui.config({ area: ['90vw', '90vh'], callBack: function (refreshCode) { winui.window.msg(systemLanguage["com.skyeye.successfulOperation"][languageType], {icon: 1, time: 2000}); - loadLingyongTable(); + loadTable(); }}); }); - // 撤销用品领用 + // 撤销 function revoke(data) { var msg = '确认撤销该用品领用申请吗?'; layer.confirm(msg, { icon: 3, title: '撤销操作' }, function (index) { layer.close(index); AjaxPostUtil.request({url: flowableBasePath + "assetarticles034", params: {processInstanceId: data.processInstanceId}, type: 'json', method: "PUT", callback: function (json) { winui.window.msg("提交成功", {icon: 1, time: 2000}); - loadLingyongTable(); + loadTable(); }}); }); } - // 编辑用品领用申请 - function useedit(data) { + // 编辑 + function edit(data) { rowId = data.id; _openNewWindows({ url: "../../tpl/assetArticlesUse/assetArticlesUseEdit.html", @@ -104,7 +104,7 @@ layui.config({ area: ['90vw', '90vh'], callBack: function (refreshCode) { winui.window.msg(systemLanguage["com.skyeye.successfulOperation"][languageType], {icon: 1, time: 2000}); - loadLingyongTable(); + loadTable(); } }); } @@ -115,12 +115,12 @@ layui.config({ layer.close(index); activitiUtil.startProcess(serviceClassName, null, function (approvalId) { var params = { - rowId: data.id, + id: data.id, approvalId: approvalId }; - AjaxPostUtil.request({url: flowableBasePath + "assetarticles023", params: params, type: 'json', callback: function (json) { + AjaxPostUtil.request({url: flowableBasePath + "assetarticles023", params: params, type: 'json', method: 'POST', callback: function (json) { winui.window.msg("提交成功", {icon: 1, time: 2000}); - loadLingyongTable(); + loadTable(); }}); }); }); @@ -131,15 +131,15 @@ layui.config({ var msg = '确认作废该条领用申请吗?'; layer.confirm(msg, { icon: 3, title: '作废操作' }, function (index) { layer.close(index); - AjaxPostUtil.request({url: flowableBasePath + "assetarticles030", params: {rowId: data.id}, type: 'json', callback: function (json) { + AjaxPostUtil.request({url: flowableBasePath + "assetarticles030", params: {id: data.id}, type: 'json', method: 'POST', callback: function (json) { winui.window.msg(systemLanguage["com.skyeye.successfulOperation"][languageType], {icon: 1, time: 2000}); - loadLingyongTable(); + loadTable(); }}); }); } // 用品领用详情 - function lingyongDedails(data) { + function details(data) { rowId = data.id; _openNewWindows({ url: "../../tpl/assetArticlesUse/assetArticlesUseDetails.html", @@ -152,35 +152,16 @@ layui.config({ } form.render(); - form.on('submit(formSearch)', function (data) { - if (winui.verifyForm(data.elem)) { - table.reloadData("lingyongTable", {page: {curr: 1}, where: getTableParams()}); - } - return false; + $("body").on("click", "#reloadTable", function() { + loadTable(); }); + function loadTable() { + table.reloadData("lingyongTable", {where: getTableParams()}); + } - // 刷新领用数据 - $("body").on("click", "#reloadLingyongTable", function() { - loadLingyongTable(); - }); - - // 刷新领用列表数据 - function loadLingyongTable(){ - table.reloadData("lingyongTable", {where: getTableParams()}); - } - - function getTableParams() { - var startTime = "", endTime = ""; - if (!isNull($("#createTime").val())) { - startTime = $("#createTime").val().split('~')[0].trim() + ' 00:00:00'; - endTime = $("#createTime").val().split('~')[1].trim() + ' 23:59:59'; - } - return { - state: $("#state").val(), - startTime: startTime, - endTime: endTime - }; - } + function getTableParams() { + return $.extend(true, {}, initTableSearchUtil.getSearchValue("lingyongTable")); + } exports('assetArticlesUseList', {}); }); diff --git a/admin-assistant/src/main/resources/template/tpl/assetArticlesUse/assetArticlesUseAdd.html b/admin-assistant/src/main/resources/template/tpl/assetArticlesUse/assetArticlesUseAdd.html index 083a00b48ffb27ef877b19f4a4b1b878f648526c..18807fb8c66acba952afbdfaeb58e1ad497373ec 100644 --- a/admin-assistant/src/main/resources/template/tpl/assetArticlesUse/assetArticlesUseAdd.html +++ b/admin-assistant/src/main/resources/template/tpl/assetArticlesUse/assetArticlesUseAdd.html @@ -11,7 +11,7 @@
-
+
@@ -29,29 +29,9 @@
-
-
-
- - -
-
- - - - - - - - - - - - - - -
用品类别*用品名称*规格(单位)库存领用数量*备注
-
+
+ +
@@ -74,19 +54,6 @@
- - - - - + {{# } }} + {{# if(d.editRow == '2'){ }} + {{# if(auth('1596957196901')){ }} + 撤销 + {{# } }} + {{# } }} + +