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

财务明细账编辑功能完成

上级 eee51e66
var userReturnList = new Array();//选择用户返回的集合或者进行回显的集合
var chooseOrNotMy = "1";//人员列表中是否包含自己--1.包含;其他参数不包含
var chooseOrNotEmail = "2";//人员列表中是否必须绑定邮箱--1.必须;其他参数没必要
var checkType = "2";//人员选择类型,1.多选;其他。单选
// 兼容动态表单
var layedit, form;
layui.config({
base: basePath,
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'jquery', 'winui', 'laydate'], function(exports) {
}).define(['window', 'jquery', 'winui', 'laydate', 'tagEditor'].concat(dsFormUtil.mastHaveImport), function(exports) {
winui.renderColor();
layui.use(['form', 'tagEditor'], function(form) {
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$,
laydate = layui.laydate;
var rowNum = 1; //表格的序号
var initemHtml = "";//收支项目
var beanTemplate = $("#beanTemplate").html();
var usetableTemplate = $("#usetableTemplate").html();
var selOption = getFileContent('tpl/template/select-option.tpl');
var handsPersonList = new Array();//经手人员
//加载单据数据
var orderObject = {};
showGrid({
id: "showForm",
url: reqBasePath + "income003",
params: {rowId: parent.rowId},
pagination: false,
template: beanTemplate,
method: "GET",
ajaxSendAfter:function(json){
//单据时间
laydate.render({
elem: '#operTime',
type: 'datetime',
trigger: 'click'
});
orderObject = json;
// 客户信息赋值
sysCustomerUtil.customerMation = {
id: json.bean.organId,
customName: json.bean.customName
}
initOtherMation();
var userNames = "";
handsPersonList = json.bean.userInfo;
$.each(handsPersonList, function (i, item) {
userNames += item.name + ',';
});
// 人员选择
$('#handsPersonId').tagEditor({
initialTags: userNames.split(','),
placeholder: '请选择经手人员',
editorTag: false,
beforeTagDelete: function(field, editor, tags, val) {
var inArray = -1;
$.each(handsPersonList, function(i, item) {
if(val === item.name) {
inArray = i;
return false;
}
});
if(inArray != -1) { //如果该元素在集合中存在
handsPersonList.splice(inArray, 1);
}
}
});
}
});
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$,
laydate = layui.laydate;
layedit = layui.layedit,
form = layui.form;
function initOtherMation() {
// 初始化账户
systemCommonUtil.getSysAccountListByType(function(json){
// 加载账户数据
$("#accountId").html(getDataUseHandlebars(selOption, json));
});
// 获取单据提交类型
var submitType = "";
// 初始化收入项目
systemCommonUtil.getSysInoutitemListByType(1, function(json){
// 加载收入项目数据
initemHtml = getDataUseHandlebars(selOption, json);
// 渲染数据到页面
initDataToShow();
});
}
var beanTemplate = $("#beanTemplate").html();
var selOption = getFileContent('tpl/template/select-option.tpl');
var handsPersonList = new Array();//经手人员
//渲染数据到页面
function initDataToShow(){
$("#accountId").val(orderObject.bean.accountId);//账户
//渲染列表项
$.each(orderObject.bean.items, function(i, item){
addRow();
$("#initemId" + (rowNum - 1)).val(item.initemId);//收入项目回显
$("#initemMoney" + (rowNum - 1)).val(item.initemMoney.toFixed(2));//金额回显
$("#remark" + (rowNum - 1)).val(item.remark);//备注回显
//设置标识
$("tr[trcusid='tr" + (rowNum - 1) + "']").attr("thisid", item.id);
showGrid({
id: "showForm",
url: reqBasePath + "income003",
params: {rowId: parent.rowId},
pagination: false,
template: beanTemplate,
method: "GET",
ajaxSendAfter:function(json){
submitType = json.bean.submitType;
// 单据时间
laydate.render({
elem: '#operTime',
type: 'datetime',
trigger: 'click'
});
matchingLanguage();
form.render();
}
form.on('submit(formEditBean)', function(data) {
if(winui.verifyForm(data.elem)) {
var rowTr = $("#useTable tr");
if(rowTr.length == 0) {
winui.window.msg('请选择收入项目.', {icon: 2, time: 2000});
return false;
// 往来单位
$("#correspondentUnitType").val(json.bean.organType);
if(json.bean.organType == 1){
// 供应商
sysSupplierUtil.supplierMation = {
id: json.bean.organId,
supplierName: json.bean.supplierName
}
var tableData = new Array();
var noError = false; //循环遍历表格数据时,是否有其他错误信息
$.each(rowTr, function(i, item) {
//获取行编号
var rowNum = $(item).attr("trcusid").replace("tr", "");
if(judgeInPoingArr(tableData, "initemId", $("#initemId" + rowNum).val())){
$("#initemId" + rowNum).addClass("layui-form-danger");
$("#initemId" + rowNum).focus();
winui.window.msg('一张单中不允许出现相同收支项目信息.', {icon: 2, time: 2000});
noError = true;
return false;
}
var row = {
initemId: $("#initemId" + rowNum).val(),
initemMoney: $("#initemMoney" +rowNum).val(),
remark: $("#remark" + rowNum).val()
};
tableData.push(row);
});
if(noError) {
return false;
}else if(json.bean.organType == 1){
// 客户信息
sysCustomerUtil.customerMation = {
id: json.bean.organId,
customName: json.bean.supplierName
}
var params = {
rowId: parent.rowId,
organId: sysCustomerUtil.customerMation.id,
handsPersonId: handsPersonList[0].id,
operTime: $("#operTime").val(),
accountId: $("#accountId").val(),
remark: $("#remark").val(),
changeAmount: $("#changeAmount").val(),
initemStr: JSON.stringify(tableData)
};
AjaxPostUtil.request({url: reqBasePath + "income004", params: params, type: 'json', method: "PUT", callback: function(json) {
if(json.returnCode == 0) {
parent.layer.close(index);
parent.refreshCode = '0';
} else {
winui.window.msg(json.returnMessage, {icon: 2, time: 2000});
}
}});
}
return false;
});
$("body").on("input", ".rkMoney", function() {
calculatedTotalPrice();
});
$("body").on("change", ".rkMoney", function() {
calculatedTotalPrice();
});
// 账套
sysIfsUtil.ifsSetOfBooksMation = {
id: json.bean.setOfBooksId,
name: json.bean.setOfBooksName
};
// 计算总价
function calculatedTotalPrice(){
var rowTr = $("#useTable tr");
var allPrice = 0;
$.each(rowTr, function(i, item) {
//获取行坐标
var rowNum = $(item).attr("trcusid").replace("tr", "");
//获取金额
var initemMoney = parseFloat(isNull($("#initemMoney" + rowNum).val()) ? "0" : $("#initemMoney" + rowNum).val());
//输出金额
$("#initemMoney" + rowNum).html((initemMoney).toFixed(2));
allPrice += initemMoney;
});
$("#allPrice").html(allPrice.toFixed(2));
}
// 类型
dsFormUtil.dsFormObjectRelationChoose = {
id: json.bean.type,
name: json.bean.typeName
};
erpOrderUtil.orderEditPageSetBtnBySubmitType(submitType, json.bean.state);
// 人员选择
$("body").on("click", "#toHandsPersonSelPeople", function(e){
userReturnList = [].concat(handsPersonList);
systemCommonUtil.openSysUserStaffChoosePage(function (staffChooseList){
// 移除所有tag
var tags = $('#handsPersonId').tagEditor('getTags')[0].tags;
for (i = 0; i < tags.length; i++) {
$('#handsPersonId').tagEditor('removeTag', tags[i]);
// 加载动态表单
dsFormUtil.loadPageToEditByObjectId("dsFormShow", json.bean.id);
initOtherMation(json);
var userNames = "";
handsPersonList = json.bean.userInfo;
$.each(handsPersonList, function (i, item) {
userNames += item.name + ',';
});
// 人员选择
$('#handsPersonId').tagEditor({
initialTags: userNames.split(','),
placeholder: '请选择经手人员',
editorTag: false,
beforeTagDelete: function(field, editor, tags, val) {
var inArray = -1;
$.each(handsPersonList, function(i, item) {
if(val === item.name) {
inArray = i;
return false;
}
});
if(inArray != -1) { //如果该元素在集合中存在
handsPersonList.splice(inArray, 1);
}
}
handsPersonList = [].concat(staffChooseList);
// 添加新的tag
$.each(handsPersonList, function(i, item){
$('#handsPersonId').tagEditor('addTag', item.name);
});
});
});
}
});
// 新增行
$("body").on("click", "#addRow", function() {
addRow();
function initOtherMation(data) {
// 初始化账户
systemCommonUtil.getSysAccountListByType(function(json){
// 加载账户数据
$("#accountId").html(getDataUseHandlebars(selOption, json));
$("#accountId").val(data.bean.accountId);
});
// 删除行
$("body").on("click", "#deleteRow", function() {
deleteRow();
});
// 初始化列表项选择
voucherUtil.initData('showVoucherUtilBox', data.bean.items);
//新增行
function addRow() {
var par = {
id: "row" + rowNum.toString(), //checkbox的id
trId: "tr" + rowNum.toString(), //行的id
initemId: "initemId" + rowNum.toString(), //收入项目id
initemMoney: "initemMoney" + rowNum.toString(), //金额id
remark: "remark" + rowNum.toString() //备注id
};
$("#useTable").append(getDataUseHandlebars(usetableTemplate, par));
//赋值给收支项目
$("#" + "initemId" + rowNum.toString()).html(initemHtml);
form.render('select');
form.render('checkbox');
rowNum++;
matchingLanguage();
form.render();
}
// 保存为草稿
form.on('submit(formEditBean)', function(data) {
if(winui.verifyForm(data.elem)) {
saveData('1', "");
}
return false;
});
// 走工作流的提交审批
form.on('submit(formSubOneBean)', function(data) {
if(winui.verifyForm(data.elem)) {
activitiUtil.startProcess(sysActivitiModel["incomeOrder"]["key"], function (approvalId) {
saveData("2", approvalId);
});
}
return false;
});
// 不走工作流的提交
form.on('submit(formSubTwoBean)', function(data) {
if(winui.verifyForm(data.elem)) {
saveData('2', "");
}
return false;
});
// 工作流中保存
form.on('submit(save)', function(data) {
if(winui.verifyForm(data.elem)) {
saveData('3', "");
}
return false;
});
//删除行
function deleteRow() {
var checkRow = $("#useTable input[type='checkbox'][name='tableCheckRow']:checked");
if(checkRow.length > 0) {
$.each(checkRow, function(i, item) {
$(item).parent().parent().remove();
});
function saveData(subType, approvalId){
var result = voucherUtil.getData();
if(result.length < 2){
return false;
}
var params = {
organType: $("#correspondentUnitType").val(),
organId: getOrganId(),
type: dsFormUtil.dsFormObjectRelationChoose.id,
handsPersonId: handsPersonList[0].id,
operTime: $("#operTime").val(),
accountId: $("#accountId").val(),
remark: $("#remark").val(),
setOfBooksId: sysIfsUtil.ifsSetOfBooksMation.id,
initemStr: JSON.stringify(result),
submitType: submitType,
subType: subType,
approvalId: approvalId,
rowId: parent.rowId
};
AjaxPostUtil.request({url: reqBasePath + "income004", params: params, type: 'json', method: "PUT", callback: function(json) {
if(json.returnCode == 0) {
dsFormUtil.savePageData("dsFormShow", json.bean.id);
parent.layer.close(index);
parent.refreshCode = '0';
} else {
winui.window.msg('请选择要删除的行', {icon: 2, time: 2000});
winui.window.msg(json.returnMessage, {icon: 2, time: 2000});
}
}});
}
function getOrganId(){
var correspondentUnitType = $("#correspondentUnitType").val();
if(correspondentUnitType == 1){
// 供应商
return sysSupplierUtil.supplierMation.id;
} else if (correspondentUnitType == 2){
// 客户
return sysCustomerUtilcustomerMation;
}
// 客户选择
$("body").on("click", "#customMationSel", function(e){
}
// 往来单位变化监听
form.on('select(correspondentUnitType)', function(data){
$("#customName").val("");
});
// 人员选择
$("body").on("click", "#toHandsPersonSelPeople", function(e){
systemCommonUtil.userReturnList = [].concat(handsPersonList);
systemCommonUtil.chooseOrNotMy = "2"; // 人员列表中是否包含自己--1.包含;其他参数不包含
systemCommonUtil.chooseOrNotEmail = "2"; // 人员列表中是否必须绑定邮箱--1.必须;其他参数没必要
systemCommonUtil.checkType = "2"; // 人员选择类型,1.多选;其他。单选
systemCommonUtil.openSysUserStaffChoosePage(function (staffChooseList){
// 移除所有tag
var tags = $('#handsPersonId').tagEditor('getTags')[0].tags;
for (i = 0; i < tags.length; i++) {
$('#handsPersonId').tagEditor('removeTag', tags[i]);
}
handsPersonList = [].concat(staffChooseList);
// 添加新的tag
$.each(handsPersonList, function(i, item){
$('#handsPersonId').tagEditor('addTag', item.name);
});
});
});
// 新增行
$("body").on("click", "#addRow", function() {
voucherUtil.addItem();
});
// 往来单位选择
$("body").on("click", "#customMationSel", function(e){
var correspondentUnitType = $("#correspondentUnitType").val();
if(correspondentUnitType == 1){
// 供应商
sysSupplierUtil.openSysSupplierChoosePage(function (supplierMation){
$("#customName").val(supplierMation.supplierName);
});
} else if (correspondentUnitType == 2){
// 客户
sysCustomerUtil.openSysCustomerChoosePage(function (customerMation){
$("#customName").val(customerMation.customName);
});
});
}
$("body").on("click", "#cancle", function() {
parent.layer.close(index);
});
// 选择账套
$("body").on("click", "#chooseSetOfBooksBtn", function(e){
var _this = $(this);
sysIfsUtil.openIfsSetOfBooksListChoosePage(function (ifsSetOfBooksMation){
_this.parent().find("input").val(ifsSetOfBooksMation.name);
});
});
// 选择单据类型
$("body").on("click", "#chooseOrderTypeBtn", function(e){
var _this = $(this);
dsFormUtil.openDsFormObjectRelationChooseByFirstTypeCodeChoosePage("IFS", function (dsFormObjectRelationChoose){
_this.parent().find("input").val(dsFormObjectRelationChoose.name);
$("#dsFormShow").html("");
// 加载动态表单
dsFormUtil.loadPageByCode("dsFormShow", null, dsFormObjectRelationChoose.id);
});
});
$("body").on("click", "#cancle", function() {
parent.layer.close(index);
});
});
\ No newline at end of file
......@@ -5,6 +5,7 @@
<title></title>
<link href="../../assets/lib/layui/css/layui.css" rel="stylesheet" />
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
<link href="../../assets/lib/winui/css/customer/voucherUtil.css" rel="stylesheet" />
</head>
<body>
<div style="margin: 0 auto; padding: 20px;">
......@@ -16,10 +17,19 @@
<!-- beanTemplate -->
<script type="text/x-handlebars-template" id="beanTemplate">
{{#bean}}
<div class="layui-form-item layui-col-xs6">
<div class="layui-form-item layui-col-xs12">
<span class="hr-title">基本信息</span><hr>
</div>
<div class="layui-form-item layui-col-xs6" style="height: 40px">
<label class="layui-form-label">往来单位<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="customName" name="customName" win-verify="required" placeholder="请选择往来单位" class="layui-input" readonly="readonly" value="{{customName}}"/>
<div class="layui-input-block" style="width: 80px">
<select id="correspondentUnitType" lay-search win-verify="required" lay-filter="correspondentUnitType" style="width: 100px">
<option value="1">供应商</option>
<option value="2">客户</option>
</select>
</div>
<div class="layui-input-block" style="width: calc(100% - 220px); top: -40px; left: 85px;">
<input type="text" id="customName" name="customName" win-verify="required" placeholder="请选择往来单位" class="layui-input" readonly="readonly" value="{{supplierName}}"/>
<i class="fa fa-plus-circle input-icon" id="customMationSel"></i>
</div>
</div>
......@@ -29,48 +39,40 @@
<input type="text" id="operTime" name="operTime" win-verify="required" placeholder="请选择单据日期" class="layui-input" value="{{billTime}}"/>
</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">
<input type="text" id="setOfBooksName" name="setOfBooksName" win-verify="required" placeholder="请选择账套" class="layui-input" readonly="readonly" value="{{setOfBooksName}}"/>
<i class="fa fa-plus-circle input-icon" id="chooseSetOfBooksBtn"></i>
</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">
<input type="text" id="orderType" name="orderType" win-verify="required" placeholder="请选择类型" class="layui-input" readonly="readonly" value="{{typeName}}"/>
<i class="fa fa-plus-circle input-icon" id="chooseOrderTypeBtn"></i>
</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">
<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 style="width: 30px;"></th>
<th style="width: 120px;">收入项目</th>
<th style="width: 80px;">金额</th>
<th style="min-width: 100px;">备注</th>
</tr>
</thead>
<tbody id="useTable" class="insurance-table">
</tbody>
</table>
</div>
</div>
<div class="layui-form-item layui-col-xs3">
<label class="layui-form-label">收款账户</label>
<div class="layui-input-block">
<select id="accountId" lay-search></select>
</div>
</div>
<div class="layui-form-item layui-col-xs3">
<label class="layui-form-label">共计金额</label>
<div class="layui-input-block ver-center" id="allPrice">
{{totalPrice}}
<div id="showVoucherUtilBox" style="overflow-x: auto;">
</div>
</div>
</div>
<div class="layui-form-item layui-col-xs3">
<label class="layui-form-label">收款金额</label>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">收款账户<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="changeAmount" name="changeAmount" win-verify="required|money" placeholder="请输入收款金额" class="layui-input" value="{{changeAmount}}"/>
<select id="accountId" lay-search win-verify="required"></select>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">经手人<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="handsPersonId" name="handsPersonId" win-verify="required" placeholder="请选择经手人员" class="layui-input" style="padding-right: 30px;"/>
......@@ -82,28 +84,26 @@
<div class="layui-input-block">
<textarea id="remark" name="remark" placeholder="请输入备注" class="layui-textarea" style="height: 100px;" maxlength="200">{{remark}}</textarea>
</div>
</div>
<div id="dsFormShow">
</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"><language showName="com.skyeye.save"></language></button>
<button class="winui-btn formEditBean layui-hide" lay-submit lay-filter="formEditBean">保存为草稿</button>
<button class="winui-btn formSubOneBean layui-hide" lay-submit lay-filter="formSubOneBean">提交审批</button>
<button class="winui-btn formSubTwoBean layui-hide" lay-submit lay-filter="formSubTwoBean">提交</button>
<button class="winui-btn save layui-hide" lay-submit lay-filter="save"><language showName="com.skyeye.save"></language></button>
</div>
</div>
{{/bean}}
</script>
<!-- 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="{{initemId}}" lay-search win-verify="required"></select></td>
<td><input type="text" class="layui-input rkMoney" id="{{initemMoney}}" win-verify="required|money"/></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 src="../../assets/lib/layui/customer/voucher/spinbox.js"></script>
<script src="../../assets/lib/layui/customer/voucher/voucherUtil.js"></script>
<script type="text/javascript">
layui.config({base: '../../js/income/'}).use('incomeEdit');
</script>
......
......@@ -60,19 +60,25 @@ var voucherUtil = {
$("#" + boxId).html(voucherUtil.tableHtmlDom);
for(var i = 0; i < data.length; i++){
voucherUtil.addItem();
var _this = $("#useTable").find("tr")[i];
_this.find(".col_summary").find("textarea").val(); // 摘要
var _this = $("#useTable").find("tr").eq(i);
_this.find(".col_summary").find("textarea").val(data[i].remark); // 摘要
_this.find(".col_voucher").find(".cell_val").attr("dataId"); // 凭证
_this.find(".col_voucher").find(".cell_val").html();
_this.find(".col_voucher").find(".cell_val").attr("dataId", data[i].voucherId); // 凭证
_this.find(".col_voucher").find(".cell_val").html(data[i].voucherName);
_this.find(".col_subject").find(".cell_val").attr("dataId", ""); // 会计科目
_this.find(".col_subject").find(".cell_val").html();
_this.find(".col_subject").find(".cell_val").attr("dataId", data[i].subjectId); // 会计科目
_this.find(".col_subject").find(".cell_val").html(data[i].subjectName);
_this.find(".col_debite").find(".cell_val").html(); // 借方金额
_this.find(".col_credit").find(".cell_val").html(); // 贷方金额
if(data[i].directionType == 1){
_this.find(".col_debite").find(".cell_val").html(data[i].eachAmount); // 借方金额
}else{
_this.find(".col_credit").find(".cell_val").html(data[i].eachAmount); // 贷方金额
}
}
$("#debit_total").text(voucherUtil.adddebit_total($(".debit_val")))
$("#credit_total").text(voucherUtil.adddebit_total($(".credit_val")))
voucherUtil.initClickEvent();
},
......@@ -156,6 +162,7 @@ var voucherUtil = {
adddebit_total: function (obj) {
var number = 0;
for (var i = 0; i < obj.length; i++) {
console.log(obj.eq(i).text())
if (obj.eq(i).text() != '') {
number = number + parseFloat(obj.eq(i).text())
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册