提交 1484dac8 编写于 作者: doc_wei's avatar doc_wei

资产申领使用新增功能修改

上级 3f77477f
......@@ -150,7 +150,7 @@ layui.config({
}
function getTableParams() {
return $.extend(true, {}, initTableSearchUtil.getSearchValue("assetlistTable"));
return $.extend(true, {}, initTableSearchUtil.getSearchValue("messageTable"));
}
exports('assetManageChoose', {});
......
......@@ -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) {
}});
......
......@@ -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");
......
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('<img src="' + systemCommonUtil.getFilePath(checkAssetReportMation.assetImg) + '" class="photo-img">');
$("#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);
});
......
......@@ -82,5 +82,5 @@ layui.config({
return $.extend(true, {assetId: parent.rowId}, initTableSearchUtil.getSearchValue("messageTable"));
}
exports('assetReportUnUseList', {});
exports('assetReportList', {});
});
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 '<img src="' + systemCommonUtil.getFilePath(d.assetImg) + '" class="photo-img" lay-event="assetImg">';
}},
{ 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
......@@ -29,27 +29,8 @@
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">资产<i class="red">*</i></label>
<div class="layui-input-block">
<div class="winui-toolbar">
<div class="winui-tool" style="text-align: left;">
<button id="addRow" class="winui-toolbtn" type="button"><i class="fa fa-plus" aria-hidden="true"></i>新增行</button>
<button id="deleteRow" class="winui-toolbtn" type="button"><i class="fa fa-trash-o" aria-hidden="true"></i>删除行</button>
</div>
</div>
<table class="layui-table">
<thead>
<tr>
<th></th>
<th>资产类别<i class="red">*</i></th>
<th>资产名称<i class="red">*</i></th>
<th style="min-width: 100px;">规格</th>
<th style="min-width: 100px;">编号</th>
<th>备注</th>
</tr>
</thead>
<tbody id="useTable" class="insurance-table">
</tbody>
</table>
<div class="layui-input-block" id="assetReportList">
</div>
</div>
<div class="layui-form-item layui-col-xs12">
......@@ -73,18 +54,6 @@
</form>
</div>
<!-- usetableTemplate -->
<script type="text/x-handlebars-template" id="usetableTemplate">
<tr trcusid="{{trId}}">
<td><input type="checkbox" rowId="{{id}}" lay-filter="checkboxProperty" name="tableCheckRow"/></td>
<td><select id="{{typeId}}" lay-filter="selectTypeProperty" win-verify="required"></select></td>
<td><select id="{{assetId}}" lay-filter="selectAssetarProperty" win-verify="required"></select></td>
<td id="{{specificationsName}}"></td>
<td id="{{assetNum}}"></td>
<td><input type="text" class="layui-input" id="{{remark}}"/></td>
</tr>
</script>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript">
......
......@@ -19,7 +19,7 @@
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript">
layui.config({base: '../../js/assetReportManage/'}).use('assetReportUnUseList');
layui.config({base: '../../js/assetReportManage/'}).use('assetReportList');
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="../../assets/lib/layui/css/layui.css" rel="stylesheet" />
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
</head>
<body>
<div class="winui-tip alert-info" id="showInfo">
</div>
<div class="winui-toolbar">
<div class="winui-tool">
<button id="reloadTable" class="winui-toolbtn search-table-btn-right"><i class="fa fa-refresh" aria-hidden="true"></i><language showName="com.skyeye.refreshDataBtn"></language></button>
<button id="saveCheckBox" class="winui-toolbtn search-table-btn-right" type="button"><i class="fa fa-save" aria-hidden="true"></i><language showName="com.skyeye.save"></language></button>
</div>
</div>
<div style="margin:auto 10px;">
<div style="margin:auto 10px;">
<table id="messageTable" lay-filter="messageTable"></table>
</div>
</div>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript">
layui.config({base: '../../js/assetReportManage/'}).use('assetReportUnUseChoose');
</script>
</body>
</html>
\ No newline at end of file
......@@ -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);
}
}
});
},
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册