From 1484dac8afaf7f95bebf9a78757dea4188674b6f Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Tue, 23 Aug 2022 23:45:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E4=BA=A7=E7=94=B3=E9=A2=86=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/assetManage/assetManageChoose.js | 2 +- .../js/assetManage/assetManageList.js | 4 +- .../assetManagePurchaseAdd.js | 2 +- .../js/assetManageUse/assetManageUseAdd.js | 202 +++++------------- ...tReportUnUseList.js => assetReportList.js} | 2 +- .../assetReportUnUseChoose.js | 140 ++++++++++++ .../tpl/assetManageUse/assetManageUseAdd.html | 35 +-- ...ortUnUseList.html => assetReportList.html} | 2 +- .../assetReportUnUseChoose.html | 30 +++ .../lib/layui/customer/adminAssistantUtil.js | 21 ++ 10 files changed, 247 insertions(+), 193 deletions(-) rename admin-assistant/src/main/resources/template/js/assetReportManage/{assetReportUnUseList.js => assetReportList.js} (98%) create mode 100644 admin-assistant/src/main/resources/template/js/assetReportManage/assetReportUnUseChoose.js rename admin-assistant/src/main/resources/template/tpl/assetReportManage/{assetReportUnUseList.html => assetReportList.html} (96%) create mode 100644 admin-assistant/src/main/resources/template/tpl/assetReportManage/assetReportUnUseChoose.html diff --git a/admin-assistant/src/main/resources/template/js/assetManage/assetManageChoose.js b/admin-assistant/src/main/resources/template/js/assetManage/assetManageChoose.js index b83d2686c..bfdc5bca4 100644 --- a/admin-assistant/src/main/resources/template/js/assetManage/assetManageChoose.js +++ b/admin-assistant/src/main/resources/template/js/assetManage/assetManageChoose.js @@ -150,7 +150,7 @@ layui.config({ } function getTableParams() { - return $.extend(true, {}, initTableSearchUtil.getSearchValue("assetlistTable")); + return $.extend(true, {}, initTableSearchUtil.getSearchValue("messageTable")); } exports('assetManageChoose', {}); diff --git a/admin-assistant/src/main/resources/template/js/assetManage/assetManageList.js b/admin-assistant/src/main/resources/template/js/assetManage/assetManageList.js index f3efa9717..a8a1f4f10 100644 --- a/admin-assistant/src/main/resources/template/js/assetManage/assetManageList.js +++ b/admin-assistant/src/main/resources/template/js/assetManage/assetManageList.js @@ -86,9 +86,9 @@ layui.config({ function assetReport(data) { rowId = data.id; _openNewWindows({ - url: "../../tpl/assetReportManage/assetReportUnUseList.html", + url: "../../tpl/assetReportManage/assetReportList.html", title: '资产明细', - pageId: "assetReportUnUseList", + pageId: "assetReportList", area: ['90vw', '90vh'], callBack: function (refreshCode) { }}); diff --git a/admin-assistant/src/main/resources/template/js/assetManagePurchase/assetManagePurchaseAdd.js b/admin-assistant/src/main/resources/template/js/assetManagePurchase/assetManagePurchaseAdd.js index 6085958d3..a1374c925 100644 --- a/admin-assistant/src/main/resources/template/js/assetManagePurchase/assetManagePurchaseAdd.js +++ b/admin-assistant/src/main/resources/template/js/assetManagePurchase/assetManagePurchaseAdd.js @@ -104,7 +104,7 @@ layui.config({ var tableData = new Array(); var noError = false; $.each(result.dataList, function(i, item) { - //获取行编号 + // 获取行编号 var thisRowKey = item["trcusid"].replace("tr", ""); if (parseInt(item.rkNum) == 0) { $("#number" + thisRowKey).addClass("layui-form-danger"); diff --git a/admin-assistant/src/main/resources/template/js/assetManageUse/assetManageUseAdd.js b/admin-assistant/src/main/resources/template/js/assetManageUse/assetManageUseAdd.js index 1bc384feb..8a22e1460 100644 --- a/admin-assistant/src/main/resources/template/js/assetManageUse/assetManageUseAdd.js +++ b/admin-assistant/src/main/resources/template/js/assetManageUse/assetManageUseAdd.js @@ -1,4 +1,3 @@ -var assetList = new Array(); //资产集合 // 资产领用 layui.config({ @@ -11,11 +10,8 @@ layui.config({ var index = parent.layer.getFrameIndex(window.name); var $ = layui.$, form = layui.form; - var rowNum = 1; //表格的序号 - var typeHtml = ""; - var usetableTemplate = $("#usetableTemplate").html(); - var selOption = getFileContent('tpl/template/select-option.tpl'); + var allChooseAssetReport = {}; // 获取当前登录员工信息 systemCommonUtil.getSysCurrentLoginUserMation(function (data) { @@ -23,59 +19,30 @@ layui.config({ $("#useName").html(data.bean.userName); }); - // 资产类型 - sysDictDataUtil.queryDictDataListByDictTypeCode(sysDictData["admAssetType"]["key"], function (data) { - typeHtml = getDataUseHandlebars(selOption, data); + skyeyeEnclosure.init('enclosureUpload'); + + // 资产 + initTableChooseUtil.initTable({ + id: "assetReportList", + cols: [ + {id: 'assetReportId', title: '资产', formType: 'chooseInput', width: '150', iconClassName: 'chooseAssetReportBtn', verify: 'required'}, + {id: 'assetNum', title: '编号', formType: 'detail', width: '150'}, + {id: 'assetImg', title: '图片', formType: 'detail', width: '80'}, + {id: 'storageArea', title: '存放区域', formType: 'detail', width: '150'}, + {id: 'remark', title: '备注', formType: 'input', width: '100'} + ], + deleteRowCallback: function (trcusid) { + delete allChooseAssetReport[trcusid]; + }, + addRowCallback: function (trcusid) { + }, + form: form, + minData: 1 }); 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, assetList)) { - //类型对应的资产存在js对象中 - var list = getListPointArray(thisRowValue, assetList); - resetAssetList(thisRowNum, list); //重置选择行的资产列表 - } else { - //类型对应的资产不存在js对象中 - AjaxPostUtil.request({url: flowableBasePath + "asset011", params: {typeId: thisRowValue}, type: 'json', callback: function(json) { - assetList.push({ - id: thisRowValue, - list: json.rows - }); - resetAssetList(thisRowNum, json.rows); //重置选择行的资产列表 - }}); - } - } - }); - - //商品加载变化事件 - form.on('select(selectAssetarProperty)', function(data) { - var thisRowNum = data.elem.id.replace("assetId", ""); - var thisRowValue = data.value; - var thisRowTypeChooseId = $("#typeId" + thisRowNum).val(); - if (!isNull(thisRowValue) && thisRowValue != '请选择') { - var list = getListPointArray(thisRowTypeChooseId, assetList); - $.each(list, function(i, item) { - if(item.id === thisRowValue) { - $("#specificationsName" + thisRowNum).html(item.specificationsName); - $("#assetNum" + thisRowNum).html(item.assetNum); - return false; - } - }); - } else { - $("#specificationsName" + thisRowNum).html(""); //重置规格为空 - $("#assetNum" + thisRowNum).html(""); //重置编号为空 - } - }); - // 初始化一行数据 - addRow(); - - skyeyeEnclosure.init('enclosureUpload'); // 保存为草稿 form.on('submit(formAddBean)', function(data) { if(winui.verifyForm(data.elem)) { @@ -95,37 +62,33 @@ 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('assetReportList'); + 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 assetNum = parseInt($("#assetNum" + rowNum).html()); - if(inTableDataArrayByAssetarId($("#assetId" + rowNum).val(), tableData)){ - winui.window.msg('领用单存在相同的用品', {icon: 2, time: 2000}); + var noError = false; + $.each(result.dataList, function(i, item) { + // 获取行编号 + var thisRowKey = item["trcusid"].replace("tr", ""); + + var assetReport = allChooseAssetReport["tr" + thisRowKey]; + if (judgeInPoingArr(tableData, "assetReportId", assetReport.id)) { + winui.window.msg('领用单存在相同的资产', {icon: 2, time: 2000}); noError = true; return false; } - var row = { - typeId: $("#typeId" + rowNum).val(), - assetId: $("#assetId" + rowNum).val(), - remark: $("#remark" + rowNum).val() - }; - tableData.push(row); + item["assetReportId"] = assetReport.id; + tableData.push(item); }); - if(noError) { + if (noError) { return false; } var params = { title: $("#useTitle").html(), remark: $("#remark").val(), - assetListStr: JSON.stringify(tableData), + assetReportListStr: JSON.stringify(tableData), enclosureInfo: skyeyeEnclosure.getEnclosureIdsByBoxId('enclosureUpload'), subType: subType, // 表单类型 1.保存草稿 2.提交审批 approvalId: approvalId @@ -136,94 +99,25 @@ layui.config({ }}); } - //判断选中的用品是否也在数组中 - function inTableDataArrayByAssetarId(str, array) { - var isIn = false; - $.each(array, function(i, item) { - if(item.assetId === str) { - isIn = true; - return false; - } + $("body").on("click", ".chooseAssetReportBtn", function() { + var trId = $(this).parent().parent().attr("trcusid"); + adminAssistantUtil.assetReportCheckType = false; // 选择类型,默认单选,true:多选,false:单选 + adminAssistantUtil.openAssetReportChoosePage(function (checkAssetReportMation){ + // 获取表格行号 + var thisRowKey = trId.replace("tr", ""); + $("#assetReportId" + thisRowKey.toString()).val(checkAssetReportMation.assetName); + $("#assetNum" + thisRowKey.toString()).html(checkAssetReportMation.assetNum); + $("#assetImg" + thisRowKey.toString()).html(''); + $("#storageArea" + thisRowKey.toString()).html(checkAssetReportMation.storageArea); + allChooseAssetReport[trId] = checkAssetReportMation; }); - return isIn; - } - - //新增行 - $("body").on("click", "#addRow", function() { - addRow(); }); - //删除行 - $("body").on("click", "#deleteRow", function() { - deleteRow(); + // 图片查看 + $("body").on("click", ".photo-img", function() { + systemCommonUtil.showPicImg($(this).attr("src")); }); - //新增行 - function addRow() { - var par = { - id: "row" + rowNum.toString(), //checkbox的id - trId: "tr" + rowNum.toString(), //行的id - typeId: "typeId" + rowNum.toString(), //类型id - assetId: "assetId" + rowNum.toString(), //资产id - specificationsName: "specificationsName" + rowNum.toString(), //规格id - assetNum: "assetNum" + 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 - }); - $("#assetId" + thisRowNum).html(sHtml); //重置商品列表下拉框 - $("#specificationsName" + thisRowNum).html(""); //重置规格为空 - $("#assetNum" + 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/assetReportManage/assetReportUnUseList.js b/admin-assistant/src/main/resources/template/js/assetReportManage/assetReportList.js similarity index 98% rename from admin-assistant/src/main/resources/template/js/assetReportManage/assetReportUnUseList.js rename to admin-assistant/src/main/resources/template/js/assetReportManage/assetReportList.js index 027faf7ea..07d9252d4 100644 --- a/admin-assistant/src/main/resources/template/js/assetReportManage/assetReportUnUseList.js +++ b/admin-assistant/src/main/resources/template/js/assetReportManage/assetReportList.js @@ -82,5 +82,5 @@ layui.config({ return $.extend(true, {assetId: parent.rowId}, initTableSearchUtil.getSearchValue("messageTable")); } - exports('assetReportUnUseList', {}); + exports('assetReportList', {}); }); diff --git a/admin-assistant/src/main/resources/template/js/assetReportManage/assetReportUnUseChoose.js b/admin-assistant/src/main/resources/template/js/assetReportManage/assetReportUnUseChoose.js new file mode 100644 index 000000000..a9bfdc224 --- /dev/null +++ b/admin-assistant/src/main/resources/template/js/assetReportManage/assetReportUnUseChoose.js @@ -0,0 +1,140 @@ + +layui.config({ + base: basePath, + version: skyeyeVersion +}).extend({ + window: 'js/winui.window' +}).define(['window', 'table', 'jquery', 'winui', 'form', 'tableCheckBoxUtil'], function (exports) { + winui.renderColor(); + var index = parent.layer.getFrameIndex(window.name); + var $ = layui.$, + form = layui.form, + table = layui.table, + tableCheckBoxUtil = layui.tableCheckBoxUtil; + + // 选择类型,默认单选,true:多选,false:单选 + var assetReportCheckType = isNull(parent.adminAssistantUtil.assetReportCheckType) ? false : parent.adminAssistantUtil.assetReportCheckType; + + // 设置提示信息 + var s = '资产明细选择规则:'; + if(assetReportCheckType){ + s += '1.多选;如没有查到要选择的资产信息,请检查资产信息是否满足当前规则。'; + // 多选保存的资产对象信息 + var checkAssetReportMation = [].concat(parent.adminAssistantUtil.checkAssetReportMation); + // 初始化值 + var ids = []; + $.each(checkAssetReportMation, function(i, item) { + ids.push(item.id); + }); + tableCheckBoxUtil.setIds({ + gridId: 'messageTable', + fieldName: 'id', + ids: ids + }); + tableCheckBoxUtil.init({ + gridId: 'messageTable', + filterId: 'messageTable', + fieldName: 'id' + }); + } else { + s += '双击要选择的数据即可选中'; + $("#saveCheckBox").hide(); + } + $("#showInfo").html(s); + + table.render({ + id: 'messageTable', + elem: '#messageTable', + method: 'post', + url: flowableBasePath + 'queryUnUseAssetReportList', + where: getTableParams(), + even: true, + page: true, + limits: getLimits(), + limit: getLimit(), + cols: [[ + { type: assetReportCheckType ? 'checkbox' : 'radio', rowspan: '3', fixed: 'left' }, + { title: systemLanguage["com.skyeye.serialNumber"][languageType], rowspan: '3', fixed: 'left', type: 'numbers' }, + { field: 'assetName', title: '资产名称', width: 120 }, + { field: 'assetImg', title: '图片', align: 'center', width: 60, templet: function (d) { + return ''; + }}, + { field: 'typeName', title: '资产类型', width: 100 }, + { field: 'assetNum', title: '资产编号', width: 160 }, + { field: 'storageArea', title: '存放区域', width: 80 }, + { field: 'assetAdmin', title: '负责人', width: 120 } + ]], + done: function(res) { + matchingLanguage(); + + initTableSearchUtil.initAdvancedSearch(this, res.searchFilter, form, "请输入资产名称,资产编号", function () { + table.reloadData("messageTable", {page: {curr: 1}, where: getTableParams()}); + }); + if (assetReportCheckType) { + // 设置选中 + tableCheckBoxUtil.checkedDefault({ + gridId: 'messageTable', + fieldName: 'id' + }); + } else { + $('#messageTable').next().find('.layui-table-body').find("table" ).find("tbody").children("tr").on('dblclick',function() { + var dubClick = $('#messageTable').next().find('.layui-table-body').find("table").find("tbody").find(".layui-table-hover"); + dubClick.find("input[type='radio']").prop("checked", true); + form.render(); + var chooseIndex = JSON.stringify(dubClick.data('index')); + var obj = res.rows[chooseIndex]; + parent.adminAssistantUtil.checkAssetReportMation = obj; + + parent.refreshCode = '0'; + parent.layer.close(index); + }); + + $('#messageTable').next().find('.layui-table-body').find("table" ).find("tbody").children("tr").on('click',function() { + var click = $('#messageTable').next().find('.layui-table-body').find("table").find("tbody").find(".layui-table-hover"); + click.find("input[type='radio']").prop("checked", true); + form.render(); + }); + } + } + }); + + table.on('tool(messageTable)', function (obj) { + var data = obj.data; + var layEvent = obj.event; + if (layEvent === 'assetImg') { // 图片预览 + systemCommonUtil.showPicImg(systemCommonUtil.getFilePath(data.assetImg)); + } + }); + + // 保存 + $("body").on("click", "#saveCheckBox", function() { + var selectedData = tableCheckBoxUtil.getValue({ + gridId: 'messageTable' + }); + if (selectedData.length == 0) { + winui.window.msg("请选择资产", {icon: 2, time: 2000}); + return false; + } + AjaxPostUtil.request({url: flowableBasePath + "queryAssetReportListByIds", params: {ids: selectedData.toString()}, type: 'json', method: "POST", callback: function (json) { + parent.adminAssistantUtil.checkAssetReportMation = [].concat(json.rows); + parent.layer.close(index); + parent.refreshCode = '0'; + }}); + }); + + form.render(); + + $("body").on("click", "#reloadTable", function() { + loadTable(); + }); + + function loadTable() { + table.reloadData("messageTable", {where: getTableParams()}); + } + + function getTableParams() { + return $.extend(true, {}, initTableSearchUtil.getSearchValue("messageTable")); + } + + exports('assetReportUnUseChoose', {}); +}); \ No newline at end of file diff --git a/admin-assistant/src/main/resources/template/tpl/assetManageUse/assetManageUseAdd.html b/admin-assistant/src/main/resources/template/tpl/assetManageUse/assetManageUseAdd.html index 17bc76e63..048d8e01d 100644 --- a/admin-assistant/src/main/resources/template/tpl/assetManageUse/assetManageUseAdd.html +++ b/admin-assistant/src/main/resources/template/tpl/assetManageUse/assetManageUseAdd.html @@ -29,27 +29,8 @@
-
-
-
- - -
-
- - - - - - - - - - - - - -
资产类别*资产名称*规格编号备注
+
+
@@ -73,18 +54,6 @@
- - - \ No newline at end of file diff --git a/admin-assistant/src/main/resources/template/tpl/assetReportManage/assetReportUnUseChoose.html b/admin-assistant/src/main/resources/template/tpl/assetReportManage/assetReportUnUseChoose.html new file mode 100644 index 000000000..5610a229c --- /dev/null +++ b/admin-assistant/src/main/resources/template/tpl/assetReportManage/assetReportUnUseChoose.html @@ -0,0 +1,30 @@ + + + + + + + + + +
+ +
+
+
+ + +
+
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/web/src/main/resources/template/assets/lib/layui/customer/adminAssistantUtil.js b/web/src/main/resources/template/assets/lib/layui/customer/adminAssistantUtil.js index 7dc286bff..9d0896773 100644 --- a/web/src/main/resources/template/assets/lib/layui/customer/adminAssistantUtil.js +++ b/web/src/main/resources/template/assets/lib/layui/customer/adminAssistantUtil.js @@ -36,4 +36,25 @@ var adminAssistantUtil = { }); }, + /** + * 未申领资产明细选择页面 + * + * @param callback 回调函数 + */ + assetReportCheckType: false, // 选择类型,默认单选,true:多选,false:单选 + checkAssetReportMation: [], // 选择时返回的对象 + openAssetReportChoosePage: function (callback) { + _openNewWindows({ + url: "../../tpl/assetReportManage/assetReportUnUseChoose.html", + title: "资产选择", + pageId: "assetReportUnUseChoose", + area: ['90vw', '90vh'], + callBack: function (refreshCode) { + if (typeof (callback) == "function") { + callback(adminAssistantUtil.checkAssetReportMation); + } + } + }); + }, + }; -- GitLab