提交 63b930e0 编写于 作者: doc_wei's avatar doc_wei

用品领用托管到表单布局

上级 36259483
var assetArticles = new Array(); //用品集合
// 用品领用
layui.config({
base: basePath,
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'jquery', 'winui', 'fileUpload', 'form'], function(exports) {
winui.renderColor();
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$,
form = layui.form;
var serviceClassName = sysServiceMation["assetArticlesUse"]["key"];
var typeHtml = "";
var selOption = getFileContent('tpl/template/select-option.tpl');
skyeyeEnclosure.init('enclosureUpload');
systemCommonUtil.getSysCurrentLoginUserMation(function (data) {
$("#title").html("用品领用申请单-" + getYMDFormatDate() + '-' + data.bean.userName);
$("#useName").html(data.bean.userName);
});
// 用品类别
sysDictDataUtil.queryDictDataListByDictTypeCode(sysDictData["admAssetArticlesType"]["key"], function (data) {
typeHtml = getDataUseHandlebars(selOption, data);
});
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
});
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 {
// 类型对应的用品不存在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
});
$("#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)) {
saveData("1", "");
}
return false;
});
// 提交审批
form.on('submit(formSubBean)', function(data) {
if(winui.verifyForm(data.elem)) {
activitiUtil.startProcess(serviceClassName, null, function (approvalId) {
saveData("2", approvalId);
});
}
return false;
});
function saveData(subType, approvalId) {
var result = initTableChooseUtil.getDataList('articlesList');
if (!result.checkResult) {
return false;
}
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(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 (judgeInPoingArr(tableData, 'articleId', $("#assetarId" + rowNum).val())) {
winui.window.msg('领用单存在相同的用品', {icon: 2, time: 2000});
noError = true;
return false;
}
tableData.push(item);
});
if (noError) {
return false;
}
var params = {
title: $("#title").html(),
remark: $("#remark").val(),
applyUseLnk: 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) {
parent.layer.close(index);
parent.refreshCode = '0';
}});
}
$("body").on("click", "#cancle", function() {
parent.layer.close(index);
});
});
\ No newline at end of file
layui.config({
base: basePath,
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'jquery', 'winui', 'form'], function (exports) {
winui.renderColor();
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$,
form = layui.form;
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();
form.render();
}});
});
\ No newline at end of file
var assetArticles = new Array(); //用品集合
// 用品领用
layui.config({
base: basePath,
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'jquery', 'winui', 'fileUpload', 'form'], function(exports) {
winui.renderColor();
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$,
form = layui.form;
var serviceClassName = sysServiceMation["assetArticlesUse"]["key"];
var typeHtml = "";
var selOption = getFileContent('tpl/template/select-option.tpl');
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});
// 用品类别
sysDictDataUtil.queryDictDataListByDictTypeCode(sysDictData["admAssetArticlesType"]["key"], function (data) {
typeHtml = getDataUseHandlebars(selOption, data);
});
initTable();
initTableChooseUtil.deleteAllRow('articlesList');
$.each(json.bean.applyUseLnk, 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();
}});
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(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
});
list = json.rows;
}, async: false});
}
return list;
}
// 根据类型重置用户列表
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)) {
saveData('1', "");
}
return false;
});
// 提交审批
form.on('submit(formSubBean)', function(data) {
if(winui.verifyForm(data.elem)) {
activitiUtil.startProcess(serviceClassName, null, function (approvalId) {
saveData("2", approvalId);
});
}
return false;
});
function saveData(subType, approvalId) {
var result = initTableChooseUtil.getDataList('articlesList');
if (!result.checkResult) {
return false;
}
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(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 (judgeInPoingArr(tableData, 'articleId', $("#assetarId" + rowNum).val())) {
winui.window.msg('领用单存在相同的用品', {icon: 2, time: 2000});
noError = true;
return false;
}
tableData.push(item);
});
if (noError) {
return false;
}
var params = {
id: parent.rowId,
title: $("#title").html(),
remark: $("#remark").val(),
applyUseLnk: 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) {
parent.layer.close(index);
parent.refreshCode = '0';
}});
}
$("body").on("click", "#cancle", function() {
parent.layer.close(index);
});
});
\ 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 style="margin:0 auto;padding:20px;">
<form class="layui-form" action="" id="showForm">
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">标题<i class="red">*</i></label>
<div class="layui-input-block ver-center" id="title">
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">步骤</label>
<div class="layui-input-block ver-center">
填单
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">责任人<i class="red">*</i></label>
<div class="layui-input-block ver-center" id="useName">
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">用品<i class="red">*</i></label>
<div class="layui-input-block" id="articlesList">
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">相关描述</label>
<div class="layui-input-block">
<textarea id="remark" name="remark" placeholder="请输入相关描述" class="layui-textarea" style="height: 100px;" maxlength="200"></textarea>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">相关附件</label>
<div class="layui-input-block" id="enclosureUpload">
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<div class="layui-input-block">
<button class="winui-btn" id="cancle"><language showName="com.skyeye.cancel"></language></button>
<button class="winui-btn" lay-submit lay-filter="formAddBean">保存为草稿</button>
<button class="winui-btn" lay-submit lay-filter="formSubBean">提交审批</button>
</div>
</div>
</form>
</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/assetArticlesUse/'}).use('assetArticlesUseAdd');
</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 style="margin:0 auto;padding:20px;">
<form class="layui-form" action="" id="showForm">
</form>
</div>
<!-- useTemplate -->
<script type="text/x-handlebars-template" id="useTemplate">
{{#bean}}
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">标题</label>
<div class="layui-input-block ver-center">
{{title}}
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">单号</label>
<div class="layui-input-block ver-center">
{{oddNumber}}
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">状态</label>
<div class="layui-input-block ver-center">
{{{stateName}}}
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">责任人</label>
<div class="layui-input-block ver-center">
{{createName}}
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">用品</label>
<div class="layui-input-block">
<table class="layui-table">
<thead>
<tr>
<th>用品类别</th>
<th>用品名称</th>
<th style="min-width: 100px;">规格(单位)</th>
<th style="min-width: 50px;">领用数量</th>
<th style="min-width: 50px;">实发数量</th>
<th>状态</th>
<th>备注</th>
</tr>
</thead>
<tbody id="useTable" class="insurance-table">
{{#each applyUseLnk}}
<tr>
<td>{{assetArticles.typeName}}</td>
<td>{{assetArticles.name}}</td>
<td>{{assetArticles.specifications}}</td>
<td>{{applyUseNum}}</td>
<td>{{actualUseNum}}</td>
<td>{{stateName}}</td>
<td>{{remark}}</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">相关描述</label>
<div class="layui-input-block ver-center">
{{remark}}
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">相关附件</label>
<div class="layui-input-block ver-center" id="enclosureUploadBtn">
</div>
</div>
{{/bean}}
</script>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript">
layui.config({base: '../../js/assetArticlesUse/'}).use('assetArticlesUseDetails');
</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 style="margin:0 auto;padding:20px;">
<form class="layui-form" action="" id="showForm">
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">标题<i class="red">*</i></label>
<div class="layui-input-block ver-center" id="title">
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">步骤</label>
<div class="layui-input-block ver-center">
填单
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">责任人<i class="red">*</i></label>
<div class="layui-input-block ver-center" id="useName">
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">用品<i class="red">*</i></label>
<div class="layui-input-block" id="articlesList">
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">相关描述</label>
<div class="layui-input-block">
<textarea id="remark" name="remark" placeholder="请输入相关描述" class="layui-textarea" style="height: 100px;" maxlength="200"></textarea>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">相关附件</label>
<div class="layui-input-block" id="enclosureUpload">
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<div class="layui-input-block">
<button class="winui-btn" id="cancle"><language showName="com.skyeye.cancel"></language></button>
<button class="winui-btn" lay-submit lay-filter="formEditBean">保存为草稿</button>
<button class="winui-btn" lay-submit lay-filter="formSubBean">提交审批</button>
</div>
</div>
</form>
</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/assetArticlesUse/'}).use('assetArticlesUseEdit');
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册