5380 lines
179 KiB
Plaintext
5380 lines
179 KiB
Plaintext
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
|
||
<%@ include file="../ini.jsp" %>
|
||
<% String id=request.getParameter("id"); if (id==null) { id="" ; } String father=request.getParameter("father"); if
|
||
(father==null) { father="" ; } %>
|
||
<!DOCTYPE HTML>
|
||
<html>
|
||
<head>
|
||
<base href="<%=basePath%>">
|
||
<title>买箱入库</title>
|
||
<jsp:include page="../inc2.jsp"></jsp:include>
|
||
<script type="text/javascript" src="js/datagrid-drag/datagrid-dnd.js"></script>
|
||
<script type="text/javascript" src="js/datagrid-drag/datagrid-head.js"></script>
|
||
<script type="text/javascript" src="jsys/chinesetopy.js"></script>
|
||
<script type="text/javascript" src="js/jquery-memoedit/jquery.memo.js"></script>
|
||
<script type="text/javascript" src="./language/language_xg.js"></script>
|
||
<script type="text/javascript" src="./datagrid-scrollview.js"></script>
|
||
|
||
</head>
|
||
|
||
<style type="text/css">
|
||
.g3-label-width {
|
||
width: 90px;
|
||
}
|
||
</style>
|
||
|
||
<body>
|
||
<form id="buyinform" method="post" style="height: 100%">
|
||
<div class="g3-flex-main">
|
||
<div class="g3-toolbar">
|
||
<input class="g3-btn-danger" id="btn_save" type="button" tag='3' onclick="saveData()" value="保存">
|
||
<input class="g3-btn-blue" id="btn_attach" type="button" tag='10' onclick="showattach1()" value="附件管理">
|
||
<input class="g3-btn-blue" id="btn_Report" type="button" tag='5' onclick="selectreport()" value="报表">
|
||
<input class="g3-btn-blue" id="btn_check" type="button" onclick="sh()" value="确认" tag='36'>
|
||
<input class="g3-btn-blue" id="btn_new" type="hidden" tag='1' onclick="newData()" value="新建">
|
||
<input class="g3-btn-blue" type="hidden" tag='2' onclick="copyData()" value="复制">
|
||
<!--
|
||
<a href="javascript:void(0)" class="easyui-linkbutton"
|
||
data-options="iconCls:'icon-copy'" onclick="copyData()">复制</a>
|
||
<a id='btn_save' href="javascript:void(0)" class="easyui-linkbutton"
|
||
data-options="iconCls:'icon-save'" onclick="saveData()"></a>
|
||
<a id='btn_save' href="javascript:void(0)" class="easyui-linkbutton"
|
||
data-options="iconCls:'icon-application-add'" onclick="showattach()">箱证</a>
|
||
<a href="javascript:void(0)" class="easyui-linkbutton"
|
||
data-options="iconCls:'icon-print'" onclick="selectreport()">报表</a>-->
|
||
</div>
|
||
<div class="g3-flex-panel" style="border: 1px solid #ddd;">
|
||
<div class="g3-top-title">
|
||
买箱入库
|
||
</div>
|
||
<div class="g3-form-row" style="width: 1024px">
|
||
<div class="g3-form-col g3col-width" id="ed_b_id">
|
||
<label class="g3-form-label g3-label-width" id="td_b_id">
|
||
买箱单号
|
||
</label>
|
||
<input id="b_id" name="b_id" type='text' style="width: 140px;"
|
||
oninput="value=value.replace(new RegExp('[^\\r\\n\u0021-\u007e]','gm'),'')">
|
||
<input id="b_type" name="b_type" type="hidden" style="width: 90px;">
|
||
<input id="b_sh" name="b_sh" type="hidden" style="width: 90px;">
|
||
</div>
|
||
<div class="g3-form-col g3col-b-width" id="ed_b_date">
|
||
<label class="g3-form-label g3-label-width" id="td_b_date">
|
||
买箱日期
|
||
</label>
|
||
<input id="b_date" name="b_date" type="text" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});"
|
||
style="width: 140px;">
|
||
</div>
|
||
<div class="g3-form-col g3col-width" id="ed_v_customer_name">
|
||
<label class="g3-form-label g3-label-width" id="td_v_customer_name">
|
||
箱公司
|
||
</label>
|
||
<input id="b_customer_id" name="b_customer_id" type="text" onchange="b_customer_idChange();"
|
||
style="width: 140px;">
|
||
<input id="v_customer_name" name="v_customer_name" readonly="readonly" type="text"
|
||
style="font-size: 12px; width: 238px">
|
||
</div>
|
||
|
||
<div class="g3-form-col g3col-width" id="ed_b_qty">
|
||
<label class="g3-form-label g3-label-width" id="td_b_qty">
|
||
购买数量
|
||
</label>
|
||
<input id="b_qty" name="b_qty" type="text" style="width: 140px;">
|
||
</div>
|
||
|
||
<div class="g3-form-col g3col-width" id="ed_b_contype">
|
||
<label class="g3-form-label g3-label-width" id="td_b_contype">
|
||
箱型
|
||
</label>
|
||
<input id="b_contype" name="b_contype" type="text" style="width: 140px;">
|
||
</div>
|
||
<div class="g3-form-col g3col-width" id="ed_v_b_atwhere_name">
|
||
<label class="g3-form-label g3-label-width" id="td_v_b_atwhere_name">
|
||
存放堆场
|
||
</label>
|
||
<input id="b_atwhere" name="b_atwhere" type="text" onchange="b_atwhereChange();"
|
||
style="width: 140px;">
|
||
<input id="v_b_atwhere_addr" name="v_b_atwhere_addr" type='hidden' style="width: 90px;">
|
||
<input id="v_b_atwhere_name" name="v_b_atwhere_name" readonly="readonly" style="width: 238px;">
|
||
</div>
|
||
<div class="g3-form-col g3col-width" id="ed_b_txid">
|
||
<label class="g3-form-label g3-label-width" id="td_b_txid">
|
||
提箱单号
|
||
</label>
|
||
<input id="b_txid" name="b_txid" type="text" style="width: 386px;">
|
||
</div>
|
||
<div hidden="hidden">
|
||
<label class="g3-form-label g3-label-width" id="td_b_xk">
|
||
业务类型
|
||
</label>
|
||
<input id="b_ywtype" name="b_ywtype" type="text" style="width: 140px;">
|
||
</div>
|
||
<div class="g3-form-col g3col-width" id="ed_v_sales_name">
|
||
<label class="g3-form-label g3-label-width" id="td_v_sales_name">
|
||
业务员:
|
||
</label>
|
||
<input id="b_sales_id" name="b_sales_id" type='hidden' style="width: 0px;">
|
||
<input id="v_sales_name" class="DDD" name="v_sales_name" onchange="v_sales_nameChange();"
|
||
style="width: 140px;">
|
||
</div>
|
||
<div class="g3-form-col g3col-width" id="ed_b_xk">
|
||
<label class="g3-form-label g3-label-width" id="td_b_xk">
|
||
箱况
|
||
</label>
|
||
<input id="b_xk" name="b_xk" style="width: 140px;" type="text">
|
||
</div>
|
||
<div class="g3-form-col g3col-width" id="ed_v_company_name">
|
||
<label class="g3-form-label g3-label-width">
|
||
我方公司:
|
||
</label>
|
||
<input id="b_mycompany_id" name="b_mycompany_id" onchange="b_mycompany_idChange();"
|
||
style="width: 140px;">
|
||
<input id="v_company_name" name="v_company_name" readonly="readonly" type="text"
|
||
style="font-size: 12px; width: 238px">
|
||
</div>
|
||
|
||
<div class="g3-form-col g3col-width" id="ed_b_amount">
|
||
<label class="g3-form-label g3-label-width" id="td_b_amount">
|
||
单价
|
||
</label>
|
||
<input id="b_amount" name="b_amount" style="width: 140px;">
|
||
</div>
|
||
<div class="g3-form-col g3col-width" id="ed_b_money_id">
|
||
<label class="g3-form-label g3-label-width" id="td_b_money_id">
|
||
币种
|
||
</label>
|
||
<input id="b_money_id" name="b_money_id" style="width: 140px;" type="text">
|
||
</div>
|
||
<div class="g3-form-col g3col-width" id="ed_b_fktk">
|
||
<label class="g3-form-label g3-label-width" id="td_b_fktk">
|
||
付款条件
|
||
</label>
|
||
<input id="b_fktk" name="b_fktk" style="width: 140px;" type="text">
|
||
</div>
|
||
<div class="g3-form-col g3col-width" id="ed_b_payment">
|
||
<label class="g3-form-label g3-label-width" id="td_b_payment">
|
||
付款方式
|
||
</label>
|
||
<input id="b_payment" name="b_payment" style="width: 140px;" type="text">
|
||
</div>
|
||
<div class="g3-form-col g3col-width" id="ed_b_teu">
|
||
<label class="g3-form-label g3-label-width" id="td_b_teu">
|
||
总TEU
|
||
</label>
|
||
<input id="b_teu" name="b_teu" style="width: 140px;" type="text">
|
||
</div>
|
||
<div class="g3-form-col g3col-b-width" id="ed_b_jqdate">
|
||
<label class="g3-form-label g3-label-width" id="td_b_jqdate">
|
||
计划交期
|
||
</label>
|
||
<input id="b_jqdate" name="b_jqdate" type="text" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'});"
|
||
style="width: 140px;">
|
||
</div>
|
||
<!-- <div class="g3-form-col g3col-width" id="ed_b_bz">
|
||
<label class="g3-form-label g3-label-width" id="td_b_bz">
|
||
备注
|
||
</label>
|
||
<textarea id="b_bz" name="b_bz" rows="1"
|
||
style="font: -webkit-small-control; font-size: 12px; width: 140px;height:19px; overflow-y: hidden;"> </textarea>
|
||
</div> -->
|
||
<div class="g3-form-col g3col-b-width" id="ed_b_bz">
|
||
<label class="g3-form-label g3-label-width" id="td_b_bz">
|
||
备注
|
||
</label>
|
||
<textarea id="b_bz" name="b_bz" rows="1"
|
||
style="font: -webkit-small-control; font-size: 12px; width: 884px;height:19px; overflow-y: hidden;"> </textarea>
|
||
</div>
|
||
|
||
<div hidden="hidden">
|
||
买入城市
|
||
<input id="b_city_id" name="b_city_id" type='hidden' style="width: 0px;">
|
||
<input id="v_cityname" name="v_cityname" onchange="v_citynameChange();" style="width: 110px;">
|
||
确认状态
|
||
<input id="b_state" name="b_state" readonly="readonly" type="text" style="width: 120px;">
|
||
资料归属
|
||
<input id="b_owner_id" name="b_owner_id" type='hidden' style="width: 0px;">
|
||
<input id="v_ownername" name="v_ownername" onchange="v_ownernameChange();" style="width: 90px;">
|
||
<div id="auto_fee">
|
||
<div id="auto_ys" style="abfloat: left;">
|
||
<table id="feegrid">
|
||
</tle>
|
||
</div>
|
||
<div id="auto_ystotal" style="float: left;">
|
||
<table>
|
||
<tr>
|
||
<td>
|
||
<span style="padding: 0px; font-size: 12px;">应收:</span>
|
||
</td>
|
||
<td>
|
||
<div id="ys_total" style="padding: 0px; font-size: 10px"></div>
|
||
</td>
|
||
<td>
|
||
<span style="padding: 0px; font-size: 12px; margin-left: 5px;">应收折人民币:</span>
|
||
</td>
|
||
<td>
|
||
<div id="ys_amount" style="padding: 0px; font-size: 10px"></div>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<span style="padding: 0px; font-size: 12px;">应付:</span>
|
||
</td>
|
||
<td>
|
||
<div id="yf_total" style="padding: 0px; font-size: 10px"></div>
|
||
</td>
|
||
<td>
|
||
<span style="padding: 0px; font-size: 12px; margin-left: 5px;">应付折人民币:</span>
|
||
</td>
|
||
<td>
|
||
<div id="yf_amount" style="padding: 0px; font-size: 10px"></div>
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>
|
||
<span style="padding: 0px; font-size: 12px;">利润:</span>
|
||
</td>
|
||
<td>
|
||
<div id="lr_total" style="padding: 0px; font-size: 10px"></div>
|
||
</td>
|
||
<td>
|
||
<span style="padding: 0px; font-size: 12px; margin-left: 5px;">利润折人民币:</span>
|
||
</td>
|
||
<td>
|
||
<div id="lr_amount" style="padding: 0px; font-size: 10px"></div>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div style="flex-grow: 1;display:flex;">
|
||
<div id="auto_sub" style="width: 70%">
|
||
<table id="subgrid" <%-- data-options="--%>
|
||
<%-- idField:'mx_xh',--%>
|
||
<%-- view:scrollview,--%>
|
||
<%-- singleSelect:false,--%>
|
||
<%-- autoRowHeight:false,--%>
|
||
<%-- pageSize:30,--%>
|
||
<%-- checkOnSelect:false,--%>
|
||
<%-- selectOnCheck:false,--%>
|
||
<%-- pagination:true,--%>
|
||
<%-- " --%>
|
||
></table>
|
||
</div>
|
||
<div id="auto_ys1" style="width: 30%">
|
||
<table id="feegridsuo"></table>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</form>
|
||
<div id='tb_sub' style="margin-bottom: 2px;display: flex">
|
||
<input id="btn_createcon" type="button" tag='3' onclick="createcon()" value="生成">
|
||
<input id="btn_append" type="button" tag='3' onclick="append_con()" value="添加">
|
||
<input hidden type="button" tag='3' onclick="insert_con()" value="插入">
|
||
<input hidden type="button" tag='3' onclick="copyrecord_con()" value="复制">
|
||
<input id="btn_remove" type="button" tag='3' onclick="removeit_con()" value="删除">
|
||
<input hidden type="button" tag='3' onclick="MoveUp('subgrid')" value="上移">
|
||
<input hidden type="button" tag='3' onclick="MoveDown('subgrid')" value="下移">
|
||
<input hidden type="button" onclick="savecolumn_con()" value="栏位设定">
|
||
<input id="btn_loadfee" type="button" onclick="insertyf()" tag='3' value="导入费用">
|
||
<input id="btn_allfee" type="button" onclick="showAllcw()" value="全费用">
|
||
<input id="btn_inputfee" type="button" onclick="showcw()" value="费用录入">
|
||
<input id="btn_plselect" type="button" onclick="selectcon_pl()" value="批量勾选">
|
||
<input id="more" type="button" name="btn_con" onclick="showsortmenu(event)" value="更多功能">
|
||
<div id="sortmenu" class="easyui-menu" style="width: 150px;">
|
||
<!-- <div name="btn_con" onClick="createconno()">
|
||
生成临时箱号
|
||
</div>-->
|
||
<div onClick="createcon_pl()" id="menu_createconpl" tag='3'>
|
||
批量生成箱子
|
||
</div>
|
||
<div onClick="updatecondata('箱型')" id="menu_updatecondata" tag='3'>
|
||
刷新箱型
|
||
</div>
|
||
<div onClick="updatecondata('存放堆场')" id="menu_updatecondata" tag='3'>
|
||
刷新存放堆场
|
||
</div>
|
||
<div onClick="updatecondata('提箱单号')" id="menu_updatecondata" tag='3'>
|
||
刷新提箱单号
|
||
</div>
|
||
<div onClick="updatecondata('箱况')" id="menu_updatecondata" tag='3'>
|
||
刷新箱况
|
||
</div>
|
||
|
||
|
||
<div onClick="importcwexcel()" id="menu_importexcel" tag='3'>
|
||
Excel导入费用
|
||
</div>
|
||
<div onClick="printtoexcel()" id="menu_excel" tag='6'>
|
||
导出excel
|
||
</div>
|
||
<div onclick="savecolumn_con()" id="menu_saveset" tag="9">
|
||
栏位设定
|
||
</div>
|
||
<div onClick="showconlog()">
|
||
删除日志
|
||
</div>
|
||
|
||
</div>
|
||
<!-- <input tag='5' type="button" onclick="printtoexcel()"
|
||
value="导出excel">-->
|
||
|
||
<!-- <input id='btn_updatecon' type="button" onclick="updateconno()" value="更新箱号">
|
||
<input id='btn_delcon' type="button" onclick="delconno()" value="库存撤删">-->
|
||
|
||
<div style="margin-left: auto;display: flex;align-items: center">
|
||
<input type="text" id="searchtext_1" style="width: 160px;" />
|
||
<button type="button" onclick="searchLikeData()">查找</button>
|
||
</div>
|
||
</div>
|
||
<div id='tb_fee' style="margin-bottom: 2px; display: none;">
|
||
<input type="button" tag='3' name="btn_ys" onclick="append_fee()" value="新增">
|
||
<input type="button" tag='3' name="btn_ys" onclick="insert_fee()" value="插入">
|
||
<input type="button" tag='3' name="btn_ys" onclick="copyrecord_fee()" value="复制">
|
||
<input type="button" tag='3' name="btn_ys" onclick="removeit_fee()" value="删除">
|
||
<input type="button" tag='3' name="btn_ys" onclick="MoveUp('feegrid')" value="上移">
|
||
<input type="button" tag='3' name="btn_ys" onclick="MoveDown('feegrid')" value="下移">
|
||
<input type="button" name="btn_ys" onclick="savecolumn_fee()" value="栏位设定">
|
||
</div>
|
||
<div id="mm_subgrid" class="easyui-menu" style="width: 120px;">
|
||
<div onclick="removeit_con()" tag="3">
|
||
删除
|
||
</div>
|
||
<!-- <div onclick="MoveUp('subgrid')">
|
||
上移
|
||
</div>
|
||
<div onclick="MoveDown('subgrid')">
|
||
下移
|
||
</div> -->
|
||
<div class="menu-sep"></div>
|
||
<div onclick="savecolumn_con()" tag="9">
|
||
栏位设定
|
||
</div>
|
||
</div>
|
||
<div id="CategoryFrm"></div>
|
||
<script type="text/javascript">
|
||
var strid = "<%=id%>";
|
||
var feegridjson = "";
|
||
var subgridjson = "";
|
||
var oldformjson = "";
|
||
var loginfee = '';
|
||
var orgid = "<%=orgid%>".toLowerCase();
|
||
|
||
|
||
$(function () {
|
||
userid = "<%=userid%>";
|
||
Ffather = "<%=father%>";
|
||
var columnarray = new Array();
|
||
var fieldname = "";
|
||
var i;
|
||
feeshqx = '1';
|
||
loginfee = getfieldvaluebyid('b_user', 'b_loginfee', 'b_id', userid);
|
||
|
||
if ("<%=orgid%>" != 'demo') {
|
||
var jpowerqx = getUserPowerQX('xg_buyin', userid);
|
||
//alert(app.jsonToString(jpowerqx));
|
||
for (key in jpowerqx) {
|
||
if (jpowerqx[key] != '1') {
|
||
$("a[tag='" + key + "']").linkbutton('disable');
|
||
$(":button[tag='" + key + "']").attr("disabled", "disabled");
|
||
$(":button[tag='" + key + "']").attr("disabled", "disabled");
|
||
var itemEls = $("div[tag='" + key + "']");
|
||
for (i = 0; i < itemEls.length; i++) {
|
||
$("#mm_sh").menu('disableItem', itemEls[i]);
|
||
$("#sortmenu").menu('disableItem', itemEls[i]);
|
||
$("#mm_subgrid").menu('disableItem', itemEls[i]);
|
||
}
|
||
}
|
||
if (key == '12') {
|
||
feeshqx = jpowerqx[key];
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
$.extend($.fn.datagrid.methods, {
|
||
keyCtr: function (jq) {
|
||
return jq.each(function () {
|
||
var grid = $(this);
|
||
grid.datagrid('getPanel').panel('panel').attr('tabindex', 1).bind('keydown', function (e) {
|
||
switch (e.keyCode) {
|
||
case 38: // up
|
||
//e.preventDefault();
|
||
var editorfield = grid.datagrid('getEditor', {
|
||
index: editIndex_fee,
|
||
field: fieldname
|
||
});
|
||
var etype = editorfield.type;
|
||
//alert(editorfield.type);
|
||
//alert(etype.substring(0,12));
|
||
if (etype.substring(0, 12) == 'autocomplete') {
|
||
ifvisible = jQuery_1_2_6(editorfield.target).open();
|
||
if (ifvisible) {
|
||
return true;
|
||
};
|
||
}
|
||
//alert(ifvisible);
|
||
getfocusedcol(grid);
|
||
var newindex = -1;
|
||
var rows = grid.datagrid('getRows');
|
||
if (editIndex_fee <= 0) { return };
|
||
calculateAmount(editIndex_fee);
|
||
for (var i = editIndex_fee - 1; i >= 0; i--) {
|
||
if (rows[i].mx_sh != '1') {
|
||
newindex = i;
|
||
break;
|
||
}
|
||
}
|
||
//alert(fieldname);
|
||
if (newindex != -1) {
|
||
grid.datagrid('endEdit', editIndex_fee);
|
||
grid.datagrid('beginEdit', newindex);
|
||
editIndex_fee = newindex;
|
||
var editorfield = grid.datagrid('getEditor', {
|
||
index: editIndex_fee,
|
||
field: fieldname
|
||
});
|
||
if (editorfield) {
|
||
e.preventDefault();
|
||
editorfield.target.focus();
|
||
editorfield.target.select();
|
||
};
|
||
};
|
||
|
||
break;
|
||
case 40: // down
|
||
//e.preventDefault();
|
||
var editorfield = grid.datagrid('getEditor', {
|
||
index: editIndex_fee,
|
||
field: fieldname
|
||
});
|
||
var etype = editorfield.type;
|
||
//alert(editorfield.type);
|
||
if (etype.substring(0, 12) == 'autocomplete') {
|
||
ifvisible = jQuery_1_2_6(editorfield.target).open();
|
||
if (ifvisible) {
|
||
return true;
|
||
};
|
||
}
|
||
|
||
getfocusedcol(grid);
|
||
var newindex = -1;
|
||
var rows = grid.datagrid('getRows');
|
||
var rowcount = rows.length;
|
||
if (editIndex_fee >= rowcount - 1) { return };
|
||
calculateAmount(editIndex_fee);
|
||
for (var i = editIndex_fee + 1; i < rowcount; i++) {
|
||
if (rows[i].mx_sh != '1') {
|
||
newindex = i;
|
||
break;
|
||
}
|
||
}
|
||
//alert(columnarray.indexOf(fieldname));
|
||
if (newindex != -1) {
|
||
grid.datagrid('endEdit', editIndex_fee);
|
||
grid.datagrid('beginEdit', newindex);
|
||
editIndex_fee = newindex;
|
||
var editorfield = grid.datagrid('getEditor', {
|
||
index: editIndex_fee,
|
||
field: fieldname
|
||
});
|
||
if (editorfield) {
|
||
e.preventDefault();
|
||
editorfield.target.focus();
|
||
editorfield.target.select();
|
||
};
|
||
}
|
||
break;
|
||
case 37:
|
||
getfocusedcol(grid);
|
||
var i = columnarray.indexOf(fieldname);
|
||
if (i + 1 > columnarray.length) { return };
|
||
fieldname = columnarray[i - 1];
|
||
var editorfield = grid.datagrid('getEditor', {
|
||
index: editIndex_fee,
|
||
field: fieldname
|
||
});
|
||
if (editorfield) {
|
||
e.preventDefault();
|
||
editorfield.target.focus();
|
||
editorfield.target.select();
|
||
};
|
||
break;
|
||
case 39:
|
||
getfocusedcol(grid);
|
||
var i = columnarray.indexOf(fieldname);
|
||
if (i + 1 > columnarray.length) { return };
|
||
fieldname = columnarray[i + 1];
|
||
var editorfield = grid.datagrid('getEditor', {
|
||
index: editIndex_fee,
|
||
field: fieldname
|
||
});
|
||
if (editorfield) {
|
||
e.preventDefault();
|
||
editorfield.target.focus();
|
||
editorfield.target.select();
|
||
};
|
||
break;
|
||
case 13:
|
||
|
||
getfocusedcol(grid);
|
||
var i = columnarray.indexOf(fieldname);
|
||
if (i + 1 > columnarray.length) { return };
|
||
fieldname = columnarray[i + 1];
|
||
//alert(fieldname);
|
||
var editorfield = grid.datagrid('getEditor', {
|
||
index: editIndex_fee,
|
||
field: fieldname
|
||
});
|
||
if (editorfield) {
|
||
e.preventDefault();
|
||
editorfield.target.focus();
|
||
editorfield.target.select();
|
||
};
|
||
break;
|
||
}
|
||
});
|
||
});
|
||
}
|
||
});
|
||
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
memoedit: {
|
||
init: function (container, options) {
|
||
var input = $('<textarea style="height: 16px;margin-top: 4px;border: 1px solid #95B8E7" class="grid_memoedit"></textarea>').appendTo(container);
|
||
$(input).memoedit();
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocomplete_atwhere: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="subgrid-mx_atwhere">').appendTo(container);
|
||
|
||
setAutoComplete('.subgrid-mx_atwhere', 'v_b_othercompany_duichang', 'b_name', 'b_id', '');
|
||
jQuery_1_2_6('.subgrid-mx_atwhere').result(function (event, data, formatted) {
|
||
if (data) {
|
||
//ALERT('4444');
|
||
$('#subgrid').datagrid('getEditor', {
|
||
index: editIndex_sub,
|
||
field: 'mx_atwhere'
|
||
}).target.val(data.b_id);
|
||
/*$('#subgrid').datagrid('getEditor', {
|
||
index : editIndex_sub,
|
||
field : 'v_mx_atwhere_addr'
|
||
}).target.val(data.b_addr);*/
|
||
$('#subgrid').datagrid('getEditor', {
|
||
index: editIndex_sub,
|
||
field: 'mx_city_id'
|
||
}).target.val(data.b_city_id);
|
||
$('#subgrid').datagrid('getEditor', {
|
||
index: editIndex_sub,
|
||
field: 'v_mx_city_name'
|
||
}).target.val(data.v_city_name);
|
||
|
||
|
||
}
|
||
});
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocomplete_xk: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="subgrid-mx_xk">').appendTo(container);
|
||
// setAutoCompleteSimple('.subgrid-mx_xk',[["全新箱"],["二手箱"]]);
|
||
setAutoComplete('.subgrid-mx_xk', 'b_xiangkuang', 'b_name', 'b_id', '');
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocomplete_bz1: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="subgrid-mx_bz1">').appendTo(container);
|
||
setAutoCompleteSimple('.subgrid-mx_bz1', [["AV"], ["DM"], ["AR"], ["ASIS"]]);
|
||
//setAutoComplete('.subgrid-mx_bz1','b_xiangkuang','b_name','b_id','');
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocomplete_color: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="subgrid-mx_color">').appendTo(container);
|
||
// setAutoCompleteSimple('.subgrid-mx_xk',[["全新箱"],["二手箱"]]);
|
||
setAutoComplete('.subgrid-mx_color', 'b_color', 'b_name', 'b_id', '');
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocomplete_suogan: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="subgrid-mx_suogan">').appendTo(container);
|
||
// setAutoCompleteSimple('.subgrid-mx_xk',[["全新箱"],["二手箱"]]);
|
||
setAutoComplete('.subgrid-mx_suogan', 'b_suogan', 'b_name', 'b_id', '');
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocomplete_xz: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="subgrid-mx_xz">').appendTo(container);
|
||
setAutoCompleteSimple('.subgrid-mx_xz', [["是"], ["否"]]);
|
||
//setAutoComplete('.subgrid-mx_xz','v_b_othercompany_duichang','b_name','b_addr','');
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocomplete_checkcc: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="subgrid-mx_checkcc">').appendTo(container);
|
||
setAutoCompleteSimple('.subgrid-mx_checkcc', [["有"], ["无"]]);
|
||
//setAutoComplete('.subgrid-mx_xz','v_b_othercompany_duichang','b_name','b_addr','');
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocomplete_checksh: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="subgrid-mx_checksh">').appendTo(container);
|
||
setAutoCompleteSimple('.subgrid-mx_checksh', [["有"], ["无"]]);
|
||
//setAutoComplete('.subgrid-mx_xz','v_b_othercompany_duichang','b_name','b_addr','');
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocomplete1_ys: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="feegrid-mx_dw_id">').appendTo(container);
|
||
|
||
setAutoComplete('.feegrid-mx_dw_id', 'v_b_othercompany', 'b_id', 'b_name', '');
|
||
jQuery_1_2_6('.feegrid-mx_dw_id').result(function (event, data, formatted) {
|
||
if (data) {
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: editIndex_fee,
|
||
field: 'v_mx_dw_name'
|
||
}).target.val(data.b_name);
|
||
}
|
||
});
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
|
||
}
|
||
}
|
||
}
|
||
});
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocomplete2_ys: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="feegrid-v_mx_feetype_name">').appendTo(container);
|
||
setAutoComplete('.feegrid-v_mx_feetype_name', 'b_feetype', 'b_name', 'b_id', '');
|
||
jQuery_1_2_6('.feegrid-v_mx_feetype_name').result(function (event, data, formatted) {
|
||
if (data) {
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: editIndex_fee,
|
||
field: 'mx_feetype_id'
|
||
}).target.val(data.b_id);
|
||
}
|
||
});
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocompletejsfs: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="feegrid-mx_memo3">').appendTo(container);
|
||
setAutoComplete_moneytype('.feegrid-mx_memo3', 'b_jsfs', 'b_name', 'b_id', '');
|
||
jQuery_1_2_6('.feegrid-mx_memo3').result(function (event, data, formatted) {
|
||
|
||
if (data) {
|
||
|
||
}
|
||
|
||
//calcw();
|
||
});
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocomplete3_ys: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="feegrid-mx_moneytype_id">').appendTo(container);
|
||
setAutoComplete_moneytype('.feegrid-mx_moneytype_id', 'b_money', 'b_name', 'b_id', '');
|
||
jQuery_1_2_6('.feegrid-mx_moneytype_id').result(function (event, data, formatted) {
|
||
if (data) {
|
||
var moneytype = data.b_name;
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: editIndex_fee,
|
||
field: 'mx_moneytype_id'
|
||
}).target.val(moneytype);
|
||
|
||
var sftype = $('#feegrid').datagrid('getEditor', {
|
||
index: editIndex_fee,
|
||
field: 'mx_type_id'
|
||
}).target.val();
|
||
// alert(sftype);
|
||
|
||
var exrate = 1;
|
||
/*var Bshipingdate=$("#b_shipingdate").val();
|
||
var canmoney=true;
|
||
if((Bshipingdate != "")&&(sftype != "")){
|
||
var searchtxt=" b_money_id='"+moneytype+"' and b_qsdate<='"+Bshipingdate+"' and b_zzdate>='"+Bshipingdate+"'"
|
||
+" and b_type='"+sftype+"'";
|
||
var modrows=loaddatas('b_hl', searchtxt, 'b_id desc', '');
|
||
if(modrows.length>0){
|
||
exrate=modrows[0].b_hl;
|
||
canmoney=false;
|
||
}
|
||
}*/
|
||
//if(canmoney){
|
||
exrate = getfieldvaluebyid('b_money', 'b_hl', 'b_name', moneytype);
|
||
//}
|
||
exrate = Math.round(exrate * 100) / 100;
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: editIndex_fee,
|
||
field: 'mx_exrate'
|
||
}).target.val(exrate);
|
||
}
|
||
//calcw();
|
||
});
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocomplete5: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="feegrid-mx_level">').appendTo(container);
|
||
setAutoCompleteSimple('.feegrid-mx_level', [['1'], ['2'], ['3'], ['4'], ['5'], ['6']]);
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocomplete_ys: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="feegrid-mx_type_id">').appendTo(container);
|
||
setAutoCompleteSimple('.feegrid-mx_type_id', [['应收'], ['应付']]);
|
||
jQuery_1_2_6('.feegrid-mx_type_id').result(function (event, data, formatted) {
|
||
//calcw();
|
||
});
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
autocomplete5_ys: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="feegrid-mx_level">').appendTo(container);
|
||
setAutoCompleteSimple('.feegrid-mx_level', [['1'], ['2'], ['3'], ['4'], ['5'], ['6']]);
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
// 自定义日期选择器,兼容低版本样式
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
wdatepicker: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" onFocus="WdatePicker({});" class="subgrid-wdatepicker">').appendTo(container);
|
||
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
var input = $(target);
|
||
if (input.hasClass("addpad16") == true) {
|
||
input.width(width - 10);
|
||
} else {
|
||
input.width(width - (input.outerWidth() - input.width()));
|
||
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
// 自定义Input,兼容低版本样式
|
||
$.extend($.fn.datagrid.defaults.editors, {
|
||
text: {
|
||
init: function (container, options) {
|
||
var input = $('<input type="text" class="datagrid-editable-input">').appendTo(container);
|
||
input.css({
|
||
height: '16px',
|
||
});
|
||
return input;
|
||
},
|
||
getValue: function (target) {
|
||
return $(target).val();
|
||
},
|
||
setValue: function (target, value) {
|
||
$(target).val(value);
|
||
},
|
||
resize: function (target, width) {
|
||
$(target)._outerWidth(width);
|
||
}
|
||
}
|
||
});
|
||
|
||
//var feecolumnfield=getcolumn("v_xg_diaoxiang_cw");
|
||
//dht=$(document).height();
|
||
//$('#auto_sub').height( dht- 150-30);
|
||
// $('#auto_ys1').height( dht- 150-30);
|
||
/////////////////////////////////////////////////////
|
||
|
||
// 表格数据
|
||
let subgridRows = []
|
||
// 取消全选锁
|
||
let disableUncheckAllEvent = false;
|
||
|
||
$('#subgrid').datagrid({
|
||
idField: 'mx_xh',
|
||
fit: true,
|
||
singleSelect: true,
|
||
selectOnCheck: false,
|
||
checkOnSelect: false,
|
||
rownumbers: false, // 关闭自定义序号
|
||
onClickRow: onClickRow_sub,
|
||
onBeginEdit: onBeginEdit_sub,
|
||
scrollOnSelect: true,
|
||
toolbar: '#tb_sub',
|
||
// 虚拟滚动相关
|
||
view: scrollview,
|
||
autoRowHeight: false,
|
||
pagination: true,
|
||
pageSize: 30,
|
||
columns:
|
||
[[
|
||
{
|
||
// 自定义序号列,虚拟列表存在BUG:新增的时候序号不显示
|
||
field: 'rownumber',
|
||
title: '',
|
||
width: 30,
|
||
align: 'center',
|
||
formatter: function (value, row, index) {
|
||
return index + 1;
|
||
},
|
||
styler: function () {
|
||
return `
|
||
background-color: #efefef;
|
||
background: -webkit-linear-gradient(top, #F9F9F9 0, #efefef 100%);
|
||
background: -moz-linear-gradient(top,#F9F9F9 0,#efefef 100%);
|
||
background: -o-linear-gradient(top,#F9F9F9 0,#efefef 100%);
|
||
background: linear-gradient(to bottom, #F9F9F9 0, #efefef 100%);
|
||
background-repeat: repeat-x;
|
||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#F9F9F9,endColorstr=#efefef,GradientType=0);
|
||
padding: 0px
|
||
`
|
||
}
|
||
},
|
||
// {field:'bcheck',checkbox:true},
|
||
{ field: 'subid', hidden: true, width: 80 },
|
||
{ field: 'father', hidden: true, width: 120 },
|
||
{ field: 'mx_dw_id', hidden: true, width: 120 },
|
||
{ field: 'mx_date', hidden: true, width: 120 },
|
||
{ field: 'mx_mycompany_id', hidden: true, width: 120 },
|
||
{
|
||
field: 'v_checkmodify', title: '改', width: 30, align: 'center', formatter: function (value, rowData, rowIndex) {
|
||
return $('<a></a>', {
|
||
href: 'javascript:void(0)',
|
||
onclick: "showlog('" + '箱号' + "','" + rowData.subid + "')"
|
||
}).text(value).get(0).outerHTML;
|
||
}
|
||
},
|
||
{ field: 'mx_xh', title: '序', hidden: true, width: 30, editor: 'text' }, //
|
||
{ field: 'mx_type', hidden: true, title: '业务类型', width: 30, editor: 'text' },
|
||
{ field: 'mx_keyid', title: '系统箱号', width: 100 }, // hidden:true,
|
||
{ field: 'mx_conno', title: '箱号', width: 100, editor: 'text' },
|
||
{ field: 'mx_contype', title: '箱型', width: 60, editor: 'text' },
|
||
{ field: 'mx_ccdate', title: '制造日期', width: 75, editor: 'wdatepicker' },
|
||
{ field: 'mx_xk', title: '箱况', width: 60, editor: 'autocomplete_xk' },
|
||
{ field: 'mx_color', title: '颜色', width: 50, editor: 'autocomplete_color' },
|
||
{ field: 'mx_checkcc', title: '叉槽', width: 40, editor: 'autocomplete_checkcc' },
|
||
{ field: 'mx_suogan', title: '锁杆', width: 50, editor: 'autocomplete_suogan' },
|
||
{ field: 'mx_checksh', title: '锁盒', width: 40, editor: 'autocomplete_checksh' },
|
||
//{field:'mx_ywtype',title:'业务类型',width:100,editor:'text',hidden:true},
|
||
//{field:'mx_xz',title:'箱证',width:40,editor:'autocomplete_xz'},
|
||
{ field: 'mx_atwhere', title: '存放堆场', hidden: true, width: 100, editor: 'text' },
|
||
{ field: 'v_mx_atwhere_name', title: '存放堆场', width: 100, editor: 'autocomplete_atwhere' },
|
||
//{field:'v_mx_atwhere_addr',hidden:true,title:'堆场详细地址',width:150,editor:'text'},
|
||
{ field: 'mx_city_id', title: '存放城市', hidden: true, width: 100, editor: 'text' },
|
||
{ field: 'v_mx_city_name', title: '存放城市', hidden: true, width: 100, editor: 'text' },
|
||
{ field: 'mx_txid', title: '提箱单号', width: 100, editor: 'text' },
|
||
{ field: 'mx_zxdate', title: '进场日期', width: 86, editor: 'wdatepicker' },
|
||
{ field: 'mx_shdatetime', title: '确认日期', width: 130 },
|
||
{
|
||
field: 'v_checkyx', title: '是否使用', width: 130,
|
||
formatter: function (value, row, index) {
|
||
var mxconno = row.mx_conno;
|
||
var mxconid = row.mx_keyid;
|
||
return $('<a></a>', {
|
||
href: 'javascript:void(0)',
|
||
onclick: "parent.addTab('tabId_editconwanglai" + mxconno + "','箱子往来" + mxconno + "','<%=basePath%>jxg/viewconwanglai.jsp?conid=" + mxconid + "')"
|
||
}).text(value).get(0).outerHTML;
|
||
}, align: 'center'
|
||
},
|
||
|
||
|
||
{ field: 'v_nworderdate', title: '最后确认时间', width: 130, hidden: true },
|
||
{ field: 'mx_bz1', title: '其他特殊备注', width: 80, editor: 'autocomplete_bz1' },
|
||
{ field: 'mx_bz', title: '备注', width: 160, editor: 'text' }
|
||
]],
|
||
onClickCell: function (index, field, value) {
|
||
columnarray = getVisibleColumn('subgrid');
|
||
fieldname = field;
|
||
canedit = '0';
|
||
endEditing_sub();
|
||
var sid = $("#b_id").val();
|
||
$('#subgrid').datagrid('options').onBeginEdit = onBeginEdit_sub;
|
||
//var ($('#subgrid').datagrid('getRows')[index].v_noworderid;
|
||
|
||
|
||
// if (($('#subgrid').datagrid('getRows')[index].v_checkyx=='是')&&($("#b_sh").val()=='1')){
|
||
// //$('#subgrid').datagrid('selectRow', editIndex_sub);
|
||
// return;
|
||
// }
|
||
var row = $('#subgrid').datagrid('getRow', index);
|
||
if (!row) return;
|
||
|
||
if (row.v_checkyx == '是' && $("#b_sh").val() == '1') {
|
||
return;
|
||
}
|
||
|
||
if (endEditing_sub()) {
|
||
$('#subgrid').datagrid('beginEdit', index);
|
||
editIndex_sub = index;
|
||
setEditing_sub(index);
|
||
if (field != '') {
|
||
var editorfield = $('#subgrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: field
|
||
});
|
||
if (editorfield) {
|
||
editorfield.target.focus();
|
||
editorfield.target.select();
|
||
};
|
||
}
|
||
} else {
|
||
$('#subgrid').datagrid('selectRow', editIndex_sub);
|
||
}
|
||
},
|
||
onAfterEdit: function (index, row, changes) {
|
||
//alert('2222');
|
||
var myString = app.jsonToString(changes);
|
||
if ((myString.indexOf('v_mx_atwhere_name') >= 0)) {
|
||
var atwherename = row.v_mx_atwhere_name;
|
||
if ((atwherename == "") || (atwherename == undefined)) {
|
||
row.mx_atwhere = '';
|
||
} else {
|
||
var s = getfieldvaluebyid('v_b_othercompany', 'b_id', 'b_name', atwherename);
|
||
// alert(s);
|
||
if ((s == '') || (s == null) || (s == undefined)) {
|
||
row.mx_atwhere = '';
|
||
row.v_mx_atwhere_name = '';
|
||
} else {
|
||
row.mx_atwhere = s;
|
||
}
|
||
}
|
||
//row.mx_amount=Math.round((price*qty*exrate)*100)/100;
|
||
}
|
||
$(this).datagrid('refreshRow', index);
|
||
},
|
||
frozenColumns: [[
|
||
{
|
||
field: 'bcheck',
|
||
width: 30,
|
||
checkbox: true,
|
||
},
|
||
{
|
||
field: 'mx_attach', width: 40, sortable: true, align: 'center', formatter: function (value, rowData, rowIndex) {
|
||
if (rowData.title == 'total') { return '合计' }
|
||
return '<a href="javascript:void(0)" attr1="' + rowIndex + '" onclick="showattach(this)">箱证</a>';
|
||
}
|
||
} /*,
|
||
{field:'mx_fee',width:40,sortable:true,align:'center',formatter:function(value, rowData, rowIndex){
|
||
//if(rowData.title == 'total'){return '合计'}
|
||
return '<a href="javascript:void(0)" attr1="'+rowIndex+'" onclick="showfee(this)">费用</a>';
|
||
}} */
|
||
]],
|
||
onRowContextMenu: function (e, index, row) {
|
||
e.preventDefault();
|
||
$('#mm_subgrid').menu('show', {
|
||
left: e.pageX,
|
||
top: e.pageY
|
||
});
|
||
},
|
||
// 虚拟滚动使用相关
|
||
onCheck: function (index, row) {
|
||
},
|
||
onUncheck: function (index, row) {
|
||
|
||
},
|
||
onCheckAll: function () {
|
||
var length = subgridRows.length;
|
||
// checkAll 在虚拟表格中不生效,所以都只能使用checkRow
|
||
for (var i = 0; i < length; i++) {
|
||
$('#subgrid').datagrid('checkRow', i);
|
||
}
|
||
},
|
||
onUncheckAll: function () {
|
||
if (disableUncheckAllEvent) {
|
||
return;
|
||
}
|
||
|
||
disableUncheckAllEvent = true;
|
||
$('#subgrid').datagrid("clearChecked");
|
||
disableUncheckAllEvent = false;
|
||
},
|
||
onLoadSuccess: function () {
|
||
// 粘贴事件监听:只监听body里面的点击事件
|
||
var $gridBody = $('#subgrid').datagrid('getPanel').find('.datagrid-body');
|
||
$gridBody.on('paste', myevent);
|
||
}
|
||
})
|
||
|
||
$('#feegridsuo').datagrid({
|
||
idField: 'mx_xh',
|
||
//width:'100%',
|
||
//height:'100%',
|
||
fit: true,
|
||
singleSelect: true,
|
||
//ctrlSelect:true,
|
||
selectOnCheck: false,
|
||
checkOnSelect: false,
|
||
rownumbers: true,
|
||
onBeginEdit: onBeginEdit_fee,
|
||
columns:
|
||
[[
|
||
{ field: 'subid', hidden: true, width: 80 },
|
||
{ field: 'father', hidden: true, width: 120 },
|
||
{ field: 'mx_xh', hidden: true, width: 30, editor: 'text' },
|
||
{ field: 'mx_hstype_id', width: 30, hidden: true, editor: 'text' },
|
||
{
|
||
field: 'mx_type_id', title: '收付', width: 40, editor: {
|
||
type: 'autocomplete_ys',
|
||
options: {}
|
||
}, align: 'center'
|
||
},
|
||
{
|
||
field: 'v_mx_dw_name', title: '单位名称', width: 150, editor: 'text',//sortable:true,
|
||
halign: 'center'
|
||
},
|
||
{
|
||
field: 'v_mx_feetype_name', title: '费用名称', width: 80,
|
||
editor: {
|
||
type: 'autocomplete2_ys',
|
||
options: {}
|
||
}, align: 'center'
|
||
},
|
||
{
|
||
field: 'mx_moneytype_id', title: '币种', width: 40,
|
||
editor: {
|
||
type: 'autocomplete3_ys',
|
||
options: {}
|
||
}, align: 'center'
|
||
},
|
||
{
|
||
field: 'mx_amount_root', title: '金额', width: 60, editor: 'text',
|
||
align: 'center'
|
||
}
|
||
]]
|
||
})
|
||
|
||
$('#feegrid').datagrid({
|
||
idField: 'mx_xh',
|
||
fit: true,
|
||
singleSelect: true,
|
||
//ctrlSelect:true,
|
||
selectOnCheck: false,
|
||
checkOnSelect: false,
|
||
rownumbers: true,
|
||
//onClickRow : onClickRow_fee,
|
||
onBeginEdit: onBeginEdit_fee,
|
||
// toolbar : '#tb_fee',
|
||
columns:
|
||
[[
|
||
// {field:'bcheck',checkbox:true},
|
||
{ field: 'subid', hidden: true, width: 80 },
|
||
{ field: 'father', hidden: true, width: 120 },
|
||
{ field: 'mx_xh', hidden: true, width: 30, editor: 'text' },
|
||
{ field: 'mx_hstype_id', width: 30, hidden: true, editor: 'text' },
|
||
{
|
||
field: 'mx_dw_id', title: '单位编号', width: 60,
|
||
editor: {
|
||
type: 'autocomplete1_ys',
|
||
options: {}
|
||
}, halign: 'center'
|
||
},
|
||
{
|
||
field: 'v_mx_dw_name', title: '单位名称', width: 150, editor: 'text',//sortable:true,
|
||
halign: 'center'
|
||
},
|
||
{
|
||
field: 'mx_type_id', title: '收付', width: 40, editor: {
|
||
type: 'autocomplete_ys', options: {}
|
||
}, align: 'center'
|
||
},
|
||
{
|
||
field: 'v_mx_feetype_name', title: '费用名称', width: 80,
|
||
editor: {
|
||
type: 'autocomplete2_ys',
|
||
options: {}
|
||
}, align: 'center'
|
||
},
|
||
{
|
||
field: 'mx_feetype_id', title: '费用编号', width: 80, hidden: true,
|
||
editor: {
|
||
type: 'text',
|
||
options: {}
|
||
}, align: 'center'
|
||
},
|
||
//{field:'v_mx_moneytype_name',title:'币种',width:40,
|
||
// editor:{type:'autocomplete3',
|
||
// options:{}
|
||
// },align:'center'},
|
||
{
|
||
field: 'mx_moneytype_id', title: '币种', width: 40,
|
||
editor: {
|
||
type: 'autocomplete3_ys',
|
||
options: {}
|
||
}, align: 'center'
|
||
},
|
||
{
|
||
field: 'mx_exrate', title: '汇率', width: 40,
|
||
editor: {
|
||
type: 'text',
|
||
options: {}
|
||
},
|
||
align: 'center'
|
||
},
|
||
{
|
||
field: 'mx_price', title: '单价', width: 60,
|
||
editor: {
|
||
type: 'text'
|
||
}, align: 'center'
|
||
},
|
||
{
|
||
field: 'mx_qty', title: '数量', width: 60,
|
||
editor: {
|
||
type: 'text'
|
||
}, align: 'center'
|
||
},
|
||
{
|
||
field: 'mx_amount_root', title: '金额', width: 60, editor: 'text',
|
||
align: 'center'
|
||
},
|
||
{
|
||
field: 'mx_amount', title: '折人民币', width: 60, editor: 'text',
|
||
/*formatter: function (value, rowData, rowIndex) {
|
||
var amount_root=rowData.mx_amount_root;
|
||
var exrate=rowData.mx_exrate;
|
||
rowData.mx_amount=Math.round((amount_root*exrate)*100)/100;
|
||
return Math.round((amount_root*exrate)*100)/100;
|
||
},*/
|
||
align: 'center'
|
||
},
|
||
//{field:'mx_linkfd_id',title:'分单ID',hidden:true,width:80,editor:'memoedit',halign:'center'},
|
||
{ field: 'mx_memo2', title: '备注', width: 80, editor: 'memoedit', halign: 'center' },
|
||
// {field:'mx_memo3',title:'开票备注',width:80,editor:'memoedit',halign:'center'},
|
||
{ field: 'mx_memo3', title: '结算方式', width: 80, hidden: true, editor: 'autocompletejsfs', halign: 'center' },
|
||
{ field: 'mx_memo4', title: '备注4', hidden: true, width: 80, editor: 'memoedit', halign: 'center' },
|
||
{ field: 'mx_memo5', title: '备注5', hidden: true, width: 80, editor: 'memoedit', halign: 'center' },
|
||
{ field: 'mx_invoiceno', title: '发票号', width: 80, editor: 'text', halign: 'center' },
|
||
{ field: 'mx_invoicedate', title: '发票日期', width: 80, editor: 'wdatepicker', halign: 'center' },
|
||
|
||
{
|
||
field: 'alreadyamount', title: '已销金额', width: 60, align: 'center', formatter: function (value, rowData, rowIndex) {
|
||
return $('<a></a>', {
|
||
href: 'javascript:void(0)',
|
||
onclick: "showxzmod('" + rowData.mx_type_id + "','" + rowData.subid + "')"
|
||
}).text(value).get(0).outerHTML;
|
||
}
|
||
},
|
||
{ field: 'notamount', title: '未销金额', width: 60, align: 'center' },
|
||
{
|
||
field: 'mx_sh', title: '审核', width: 40, hidden: true, editor: {
|
||
type: 'checkbox',
|
||
options: {
|
||
on: '1',
|
||
off: '0'
|
||
}
|
||
},
|
||
formatter: function (value, row, index) {
|
||
return $("<input>", {
|
||
type: "checkbox",
|
||
//命名name会导致主表formobj打包时带上打钩信息
|
||
//name:"DataGridCheckBox",
|
||
checked: value == '1' ? "checked" : false,
|
||
disabled: ((feeshqx != '1') || (row.alreadyamount != 0)) ? "disabled" : false,
|
||
onClick: "mx_shClick(this)",
|
||
rowIndex: index
|
||
}).get(0).outerHTML;
|
||
}, align: 'center'
|
||
},
|
||
{
|
||
field: 'mx_shman_id', title: '审核人', width: 60, hidden: true,
|
||
editor: {
|
||
type: 'autocomplete',
|
||
options: {
|
||
id: 'mx_shman_id',
|
||
viewname: 'b_user',
|
||
field1: 'b_id',
|
||
field2: 'b_name',
|
||
disabled: true
|
||
}
|
||
},
|
||
formatter: function (value, row, index) {
|
||
return getfieldvaluebyid('b_user',
|
||
'b_name', 'b_id', value);
|
||
},
|
||
editor: 'text', align: 'center'
|
||
},
|
||
{ field: 'mx_shdate', title: '审核日期', width: 80, hidden: true, editor: 'text', align: 'center' },
|
||
{
|
||
field: 'mx_level', title: '级别', width: 40, hidden: true,
|
||
editor: {
|
||
type: 'autocomplete5',
|
||
options: {}
|
||
}, align: 'center'
|
||
},
|
||
{
|
||
field: 'mx_intputman_id', hidden: true,
|
||
title: '录入人',
|
||
width: 60,
|
||
editor: {
|
||
type: 'autocomplete',
|
||
options: {
|
||
id: 'mx_intputman_id',
|
||
viewname: 'b_user',
|
||
field1: 'b_id',
|
||
field2: 'b_name',
|
||
disabled: true
|
||
}
|
||
},
|
||
formatter: function (value, row, index) {
|
||
return getfieldvaluebyid('b_user',
|
||
'b_name', 'b_id', value);
|
||
}
|
||
}, {
|
||
field: 'mx_inputdate', hidden: true,
|
||
title: '录入日期',
|
||
width: 80,
|
||
editor: {
|
||
type: 'wdatepicker',
|
||
options: {
|
||
disabled: true
|
||
}
|
||
}
|
||
}
|
||
|
||
]],
|
||
frozenColumns: [[
|
||
// {field:'bcheck',checkbox:true,width:30},
|
||
{
|
||
field: 'mx_attach', width: 70, sortable: true, align: 'center', formatter: function (value, rowData, rowIndex) {
|
||
if (rowData.title == 'total') { return '合计' }
|
||
return '<a style="margin-right:10px;" attr1="' + rowIndex + '" href="javascript:void(0)" onclick="addfee(this)">添加</a>' +
|
||
'<a href="javascript:void(0)" attr1="' + rowData.mx_xh + '" onclick="removeitfee(this)">删除</a>';
|
||
}
|
||
},
|
||
]],
|
||
onClickCell: function (index, field, value) {
|
||
columnarray = getVisibleColumn('feegrid');
|
||
fieldname = field;
|
||
canedit = '0';
|
||
var editorsh = $('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_sh'
|
||
});
|
||
endEditing_fee();
|
||
if (field != 'mx_sh') {
|
||
if ($('#feegrid').datagrid('getRows')[index].mx_sh == '1') {
|
||
if (field == 'mx_invoiceno' || field == 'mx_invoicedate' || field == 'mx_memo2') {
|
||
$('#feegrid').datagrid('endEdit', editIndex_fee);
|
||
$('#feegrid').datagrid('options').onBeginEdit = function () {
|
||
return;
|
||
};
|
||
editIndex_fee = index;
|
||
if (field == 'mx_invoiceno') {
|
||
$('#feegrid').datagrid('editCell', { index: index, field: [field, 'mx_invoicedate'] });
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_invoiceno'
|
||
}).target.bind('change', function () {
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_invoicedate'
|
||
}).target.val($(this).val() ? getnowdate() : '');
|
||
}).focus().select();
|
||
} else {
|
||
$('#feegrid').datagrid('editCell', { index: index, field: [field] })
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: field
|
||
}).target.attr('readonly', 'readonly').focus().select();
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
if ($("#b_check2").is(':checked')) {
|
||
return;
|
||
}
|
||
$('#feegrid').datagrid('options').onBeginEdit = onBeginEdit_fee;
|
||
if (endEditing_fee()) {
|
||
$('#feegrid').datagrid('beginEdit', index);
|
||
editIndex_fee = index;
|
||
|
||
setEditing(index);
|
||
if (field != 'mx_sh') {
|
||
var editorfield = $('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: field
|
||
});
|
||
if (editorfield) {
|
||
editorfield.target.focus();
|
||
editorfield.target.select();
|
||
};
|
||
}
|
||
} else {
|
||
$('#feegrid').datagrid('selectRow', editIndex_fee);
|
||
}
|
||
}
|
||
|
||
}, onAfterEdit: function (index, row, changes) {
|
||
//alert('2222');
|
||
var myString = app.jsonToString(changes);
|
||
if ((myString.indexOf('mx_dw_id') >= 0) || (myString.indexOf('mx_amount_root') >= 0) ||
|
||
(myString.indexOf('mx_price') >= 0) || (myString.indexOf('mx_qty') >= 0) ||
|
||
(myString.indexOf('mx_type_id') >= 0) || (myString.indexOf('mx_feetype_id') >= 0)
|
||
|| (myString.indexOf('mx_moneytype_id') >= 0)) {
|
||
//if (app.jsonToString(changes)!='{}'){
|
||
//alert('1111');
|
||
row.mx_intputman_id = userid;
|
||
row.mx_inputdate = getnowdate();
|
||
}
|
||
|
||
if ((myString.indexOf('mx_exrate') >= 0)) {
|
||
|
||
var amount_root = row.mx_amount_root;
|
||
var price = row.mx_price;
|
||
var qty = row.mx_qty;
|
||
var exrate = row.mx_exrate;
|
||
row.mx_amount = Math.round((price * qty * exrate) * 100) / 100;
|
||
|
||
}
|
||
calcw();
|
||
|
||
$(this).datagrid('refreshRow', index);
|
||
},
|
||
rowStyler: function (index, row) {
|
||
if (row.mx_type_id == '应付') {
|
||
return 'color:red;';
|
||
}
|
||
}
|
||
}).datagrid("columnMoving");
|
||
|
||
configColumn('subgrid', 'v_xg_buyin_sub', 'local'); //'local'
|
||
|
||
// alert("122");
|
||
$("#b_bz").memoedit('');
|
||
$('#btn_updatecon').attr('disabled', 'disabled');
|
||
$('#btn_delcon').attr('disabled', 'disabled');
|
||
|
||
if (strid != "") {
|
||
loaddata(strid);
|
||
// loaddata_detail_fee('feegrid','v_xg_buyin_cw',strid,'');
|
||
|
||
loaddata_detail_sub('subgrid', 'v_xg_buyin_sub', strid, '');
|
||
if (($('#b_state').val() == '审核通过') || ($('#b_state').val() == '归档')) {
|
||
$('#btn_save').attr('disabled', 'disabled');
|
||
$('#btn_updatecon').removeAttr("disabled");
|
||
$('#btn_delcon').removeAttr("disabled");
|
||
$(":button[tag*='" + 3 + "']").attr("disabled", "disabled");
|
||
var itemEls = $("div[tag='" + 3 + "']");
|
||
for (i = 0; i < itemEls.length; i++) {
|
||
$("#mm_sh").menu('disableItem', itemEls[i]);
|
||
$("#sortmenu").menu('disableItem', itemEls[i]);
|
||
$("#mm_subgrid").menu('disableItem', itemEls[i]);
|
||
}
|
||
}
|
||
if (($('#b_sh').val() == '1')) {
|
||
//$('#btn_sh').attr('disabled','disabled');
|
||
// $('#btn_createcon').attr('disabled','disabled');
|
||
}
|
||
|
||
|
||
|
||
|
||
// calcw();
|
||
} else {
|
||
// alert("11");
|
||
// alert(getAutoID('xg_containerlib','g3soft'));
|
||
loaddefaultvalue('buyinform', 'v_xg_buyin', userid);
|
||
$('#b_id').val(getAutoID('xg_buyin', 'g3soft'));
|
||
$('#b_date').val(getnowtime());
|
||
$('#b_type').val('买箱入库');
|
||
|
||
// $('#b_bzstate').val('有效');
|
||
$('#v_ownername').val(getfieldvaluebyid('b_user', 'b_name', 'b_id', userid));
|
||
$("#b_owner_id").val(userid);
|
||
}
|
||
//alert("31");
|
||
var formobj = app.serializeObject2($('#buyinform'));
|
||
oldformjson = app.jsonToString(formobj);
|
||
// columnarray =getVisibleColumn('feegrid');
|
||
// $("#feegrid").datagrid("keyCtr");
|
||
// if($("#feegrid").datagrid("getRows").length==0){
|
||
// append_fee();
|
||
// }
|
||
//endEditing_fee();
|
||
// var gridrows=$("#feegrid").datagrid("getRows");
|
||
//feegridjson=app.jsonToString(gridrows);
|
||
});
|
||
|
||
|
||
|
||
// 搜索相关
|
||
let searchResults = [];
|
||
let currentIndex = -1;
|
||
|
||
// 同步搜索 datagrid 数据
|
||
function searchList(keyword) {
|
||
if (!keyword) {
|
||
searchResults = [];
|
||
currentIndex = -1;
|
||
return;
|
||
}
|
||
|
||
searchResults = [];
|
||
|
||
// 遍历每一行,检查每个字段是否匹配
|
||
for (let index = 0; index < subgridRows.length; index++) {
|
||
let item = subgridRows[index];
|
||
let found = false;
|
||
|
||
for (let key in item) {
|
||
if (item.hasOwnProperty(key)) {
|
||
const rawValue = item[key];
|
||
const value = (rawValue != null ? String(rawValue) : '').toLowerCase();
|
||
if (value.includes(keyword.toLowerCase())) {
|
||
found = true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (found) {
|
||
searchResults.push(index);
|
||
}
|
||
}
|
||
|
||
currentIndex = -1;
|
||
}
|
||
|
||
// 循环跳转到下一个匹配
|
||
function nextMatch() {
|
||
if (searchResults.length === 0) {
|
||
return;
|
||
}
|
||
|
||
currentIndex = (currentIndex + 1) % searchResults.length;
|
||
const index = searchResults[currentIndex];
|
||
|
||
// 同步滚动到该行并高亮
|
||
$('#subgrid').datagrid('selectRow', index);
|
||
$('#subgrid').datagrid('scrollTo', index);
|
||
}
|
||
|
||
// 搜索入口
|
||
function searchLikeData() {
|
||
const input = document.getElementById('searchtext_1');
|
||
const keyword = input.value.trim();
|
||
|
||
if (keyword === input.dataset.lastKeyword) {
|
||
nextMatch();
|
||
} else {
|
||
searchList(keyword);
|
||
input.dataset.lastKeyword = keyword;
|
||
if (searchResults.length > 0) {
|
||
nextMatch();
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
function newData() {
|
||
$('#buyinform').form('clear');
|
||
loaddefaultvalue('buyinform', 'v_xg_buyin', userid);
|
||
// $('#b_bzstate').val('有效');
|
||
// $('#b_state').val('完成');
|
||
$('#b_id').val(getAutoID('xg_buyin', 'g3soft'));
|
||
$('#v_ownername').val(getfieldvaluebyid('b_user', 'b_name', 'b_id', userid));
|
||
$('#b_id').removeAttr("readonly");
|
||
//$('#btn_save').linkbutton('enable');
|
||
$('#btn_updatecon').attr('disabled', 'disabled');
|
||
$('#btn_delcon').attr('disabled', 'disabled');
|
||
$('#btn_save').removeAttr("disabled");
|
||
$(":button[tag*='" + 3 + "']").removeAttr("disabled");
|
||
|
||
//$('#feegrid').datagrid('loadData', []);
|
||
$('#subgrid').datagrid('loadData', []);
|
||
}
|
||
|
||
|
||
function b_cftsChange() {
|
||
//calcw();
|
||
}
|
||
|
||
/*function calcw(){
|
||
|
||
var total_amount=0
|
||
|
||
var dcprice= $('#b_dcprice').val();
|
||
var cfts= $('#b_cfts').val();
|
||
if((dcprice>0)&&(cfts>0))
|
||
{
|
||
total_amount=parseFloat(dcprice)*parseFloat(cfts);
|
||
}
|
||
|
||
$('#b_dcfee').val(Math.round(total_amount*100)/100);
|
||
|
||
}*/
|
||
|
||
function loaddata(strid) {
|
||
var strid = strid;
|
||
var strtemp;
|
||
var searchcondition = "b_id='" + strid + "'";
|
||
$.ajax({
|
||
type: 'post',
|
||
url: 'jsp/loaddata.jsp',
|
||
cache: false,
|
||
async: false,
|
||
data: {
|
||
soption: 'main',
|
||
searchcondition: searchcondition,
|
||
viewname: 'v_xg_buyin',
|
||
orderfield: 'b_id'
|
||
},
|
||
dataType: 'json', // 服务器返回时接收的数据类型
|
||
success: function (result) {
|
||
//alert(result);
|
||
//strtemp=app.jsonToString(result);
|
||
//alert(strtemp);
|
||
$('#buyinform').form('load', result);
|
||
//$('#custform').form('load','mycust.json');
|
||
$('#b_id').attr('readonly', 'readonly');
|
||
//$("#b_id").attr("readonly","true");
|
||
//return strtemp;
|
||
},
|
||
error: function (result) {
|
||
}
|
||
});
|
||
//return strtemp;
|
||
}
|
||
|
||
|
||
/* function selectreport(){
|
||
var sid=$('#b_id').textbox('getText');
|
||
var cateid='买箱入库';
|
||
var valuesql=new Array();
|
||
valuesql.push("select * from v_xg_buyin where b_id='"+sid+"'");
|
||
|
||
var url="jsys/report.jsp?cateid="+cateid+"&valuesql="+valuesql;
|
||
var datadialog= parent.$('<div/>').dialog({
|
||
title: '打印报表',
|
||
width: 450,
|
||
height: 350,
|
||
content: '<iframe id="" src="' + url + '" allowTransparency="true" scrolling="auto" width="100%" height="100%" frameBorder="0" name=""></iframe>',
|
||
modal: true
|
||
});
|
||
}*/
|
||
|
||
function selectreport() {
|
||
var sid = $('#b_id').val();
|
||
var cateid = '买箱入库';
|
||
var valuesql = new Array();
|
||
valuesql.push("select * from v_xg_buyin where b_id='" + sid + "'");
|
||
valuesql.push("select * from v_xg_buyin_sub where father='" + sid + "' order by mx_xh");
|
||
valuesql.push("select * from v_xg_buyin_cw where father='" + sid + "' order by mx_xh");
|
||
var valuesql1 = valuesql.join("|");
|
||
|
||
var url = "jsys/jreportselect.jsp?cateid=" + encodeURI(cateid) + "&valuesql=" + encodeURI(valuesql1) + "&djid=" + encodeURI(sid);
|
||
var datadialog = parent.$('<div/>').dialog({
|
||
title: '打印报表',
|
||
width: 450,
|
||
height: 350,
|
||
content: '<iframe id="" src="' + url + '" allowTransparency="true" scrolling="auto" width="100%" height="99.2%" frameBorder="0" name=""></iframe>',
|
||
modal: true
|
||
});
|
||
}
|
||
|
||
|
||
|
||
|
||
function copyData() {
|
||
$('#b_id').removeAttr("readonly");
|
||
var id = $('#b_id').val();
|
||
$('#b_id').val(id + '复制');
|
||
$('#btn_updatecon').attr('disabled', 'disabled');
|
||
$('#btn_delcon').attr('disabled', 'disabled');
|
||
$(":button[tag*='" + 3 + "']").removeAttr("disabled");
|
||
// $('#feegrid').datagrid('loadData', []);
|
||
$('#subgrid').datagrid('loadData', []);
|
||
}
|
||
|
||
|
||
function totalqty() {
|
||
endEditing_sub();
|
||
var rows = subgridRows;
|
||
var irow = rows.length;
|
||
|
||
if (irow > 0) {
|
||
$("#b_qty").val(irow);
|
||
}
|
||
|
||
var teu = 0;
|
||
var contypeMap = {};
|
||
|
||
for (var i = 0; i < irow; i++) {
|
||
var contype = rows[i].mx_contype;
|
||
|
||
if (contype && contype !== "") {
|
||
|
||
// 先查缓存
|
||
var Fteu;
|
||
if (contypeMap.hasOwnProperty(contype)) {
|
||
Fteu = contypeMap[contype];
|
||
} else {
|
||
Fteu = getfieldvaluebyid('b_con_type', 'b_teu', 'b_name', contype);
|
||
contypeMap[contype] = Fteu; // 缓存结果
|
||
}
|
||
|
||
if (Math.round(Fteu * 100) / 100 != 0) {
|
||
teu += Math.round(Fteu * 100) / 100;
|
||
}
|
||
}
|
||
}
|
||
|
||
$("#b_teu").val(Math.round(teu * 100) / 100);
|
||
}
|
||
|
||
|
||
|
||
function checkcontainno() {
|
||
// 结束编辑
|
||
$('#subgrid').datagrid('endEdit', editIndex_sub);
|
||
editIndex_sub = undefined;
|
||
|
||
var sresult = 'OK';
|
||
|
||
// 清洗箱号空格
|
||
for (var i = 0; i < subgridRows.length; i++) {
|
||
if (subgridRows[i].mx_conno) {
|
||
var conno = subgridRows[i].mx_conno.trim();
|
||
subgridRows[i].mx_conno = conno;
|
||
}
|
||
}
|
||
|
||
// 执行验证
|
||
for (var i = 0; i < subgridRows.length; i++) {
|
||
if (subgridRows[i].mx_conno) {
|
||
var stmp = checkConNo(subgridRows[i].mx_conno);
|
||
if (stmp != 'OK') {
|
||
sresult = stmp;
|
||
$.sobox.alert('远通提示', stmp);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
return sresult;
|
||
}
|
||
|
||
|
||
function saveData() {
|
||
//endEditing_fee();
|
||
endEditing_sub();
|
||
if (checkcontainno() != 'OK') {
|
||
//return;
|
||
}
|
||
|
||
if (!canitemidexists()) {
|
||
//alert('箱号有重复,不能保存!');
|
||
return;
|
||
}
|
||
|
||
if ($('#b_txid').val() == '') {
|
||
alert('提箱单号不能为空,不能保存!');
|
||
return;
|
||
}
|
||
totalqty();
|
||
|
||
var flag = 'mod';
|
||
if (document.getElementById("b_id").readOnly) {
|
||
flag = 'mod';
|
||
} else {
|
||
flag = 'new';
|
||
var sid = $('#b_id').val();
|
||
sid = getAutoID('xg_buyin', 'g3soft');
|
||
if (sid != "") {
|
||
$('#b_id').val(sid);
|
||
} else {
|
||
var Fstrid = $('#b_id').val();
|
||
if (Fstrid != "") {
|
||
var Fywid = getfieldvaluebyid('xg_yw', 'subid', 'b_id', Fstrid);
|
||
if (Fywid != '') {
|
||
alert('业务单号重复,不能保存!');
|
||
return;
|
||
}
|
||
}
|
||
};
|
||
};
|
||
|
||
strid = $('#b_id').val();
|
||
var subtable = new Array();
|
||
var subinsertvalue = new Array();
|
||
var subdelvalue = new Array();
|
||
var subupdatevalue = new Array();
|
||
var keyid = new Array();
|
||
subtable.length = 0;
|
||
subtable.push('xg_buyin');
|
||
subtable.push('xg_yw');
|
||
subtable.push('xg_keyrecords');
|
||
subtable.push('xg_conmaxtype')
|
||
subtable.push('xg_buyin_sub');
|
||
subtable.push('xg_cw');
|
||
|
||
keyid.push('b_id');
|
||
keyid.push('subid');
|
||
keyid.push('subid');
|
||
keyid.push('subid');
|
||
keyid.push('subid');
|
||
keyid.push('subid');
|
||
|
||
|
||
var formobj = app.serializeObject2($('#buyinform'));
|
||
formjson = app.jsonToString(formobj);
|
||
subdelvalue.push('[]');
|
||
if (flag == 'new') {
|
||
formobj.b_inputdate = getnowtime();
|
||
formobj.b_inputuser_id = userid;
|
||
formobj.b_state = '草拟';
|
||
formobj.father = strid;
|
||
formobj.b_hstype = '买箱入库';
|
||
formjson = app.jsonToString(formobj);
|
||
subinsertvalue.push('[' + formjson + ']');
|
||
subupdatevalue.push('[]');
|
||
}
|
||
|
||
if (flag == 'mod') {
|
||
var oldjsonobj = eval('(' + oldformjson + ')');
|
||
formjson = getModifiedFieldJson(oldjsonobj, eval('(' + formjson + ')'));
|
||
if (formjson != '') {
|
||
var sss = 'b_id:' + '"' + strid + '"';
|
||
formjson = '{' + sss + ',' + formjson + '}';
|
||
} else {
|
||
var sss = 'b_id:' + '"' + strid + '"';
|
||
formjson = '{' + sss + '}';
|
||
}
|
||
subupdatevalue.push('[' + formjson + ']');
|
||
subinsertvalue.push('[]');
|
||
console.log('mod' + formjson);
|
||
}
|
||
|
||
///////////////////////////////////////////////
|
||
////////////////////////////////////
|
||
var Fsa = formjson;
|
||
var formobj = eval('(' + formjson + ')');
|
||
|
||
/*var Fstr='';
|
||
Fstr=Fstr+',father:"'+strid+'",b_hstype:"买箱入库"}';
|
||
Fsa=Fsa.substring(0, Fsa.length-1)+Fstr;
|
||
console.log('Fsa'+Fsa); */
|
||
// alert(Fsa)
|
||
insertRowsjson = '[]';
|
||
updateRowsjson = '[]';
|
||
deleteRowsjson = '[]';
|
||
var subid = getfieldvaluebyid('xg_yw', 'subid', 'b_id', strid);
|
||
if (subid == '') {
|
||
var insertRowsjson = "[" + Fsa + "]";
|
||
} else {
|
||
Fsa = Fsa.substring(0, Fsa.length - 1) + ",subid:" + subid + '}';
|
||
updateRowsjson = "[" + Fsa + "]";
|
||
}
|
||
//alert(insertRowsjson);
|
||
subdelvalue.push(deleteRowsjson);
|
||
subinsertvalue.push(insertRowsjson);
|
||
subupdatevalue.push(updateRowsjson);
|
||
|
||
////////////////////////删除xg_keyrecords////////////////////////////////////////
|
||
let oldSubgridRows = JSON.parse(subgridjson);
|
||
let delSubgridRows = oldSubgridRows
|
||
.filter(oldRow => !subgridRows.some(newRow => newRow.subid === oldRow.subid))
|
||
|
||
insertRowsjson = '[]';
|
||
updateRowsjson = '[]';
|
||
var rows = [];
|
||
var insertRows = [];
|
||
var updateRows = [];
|
||
var varupdateRows = [];
|
||
tmpdata = {};
|
||
var subdata = [];
|
||
var j = 0;
|
||
for (j in delSubgridRows) {
|
||
var conkeyid = delSubgridRows[j].mx_keyid;
|
||
if ((conkeyid == '') || (conkeyid == undefined) || (conkeyid == null)) {
|
||
continue;
|
||
}
|
||
var searchsql1 = " father ='" + strid + "' " + " and mx_keyid ='" + conkeyid + "' ";
|
||
var xgrecordsrows = loaddatas('xg_keyrecords', searchsql1, 'subid', '');
|
||
if (xgrecordsrows.length > 0) {
|
||
tmpdata = {};
|
||
tmpdata.subid = xgrecordsrows[0].subid;
|
||
subdata.push(tmpdata);
|
||
} else {
|
||
alert('箱子信息出错,保存失败!');
|
||
return;
|
||
}
|
||
}
|
||
var deleteRowsjson = app.jsonToString(subdata);
|
||
// console.log('subdata'+deleteRowsjson);
|
||
subdelvalue.push(deleteRowsjson);
|
||
subinsertvalue.push(insertRowsjson);
|
||
subupdatevalue.push(updateRowsjson);
|
||
////////////////////////
|
||
|
||
////////////////////////删除最新xg_conmaxtype////////////////////////////////////////
|
||
insertRowsjson = '[]';
|
||
updateRowsjson = '[]';
|
||
var rows = [];
|
||
var insertRows = [];
|
||
var updateRows = [];
|
||
var varupdateRows = [];
|
||
|
||
tmpdata1 = {};
|
||
var subdata1 = [];
|
||
var t = 0;
|
||
for (t in delSubgridRows) {
|
||
var conkeyid = delSubgridRows[t].mx_keyid;
|
||
if ((conkeyid == '') || (conkeyid == undefined) || (conkeyid == null)) {
|
||
continue;
|
||
}
|
||
var searchsql1 = " father ='" + strid + "' " + " and mx_keyid ='" + conkeyid + "'";
|
||
|
||
// console.log(searchsql1)
|
||
var xgmaxrows = loaddatas('xg_conmaxtype', searchsql1, 'subid', '');
|
||
if (xgmaxrows.length > 0) {
|
||
tmpdata1 = {};
|
||
tmpdata1.subid = xgmaxrows[0].subid;
|
||
subdata1.push(tmpdata1);
|
||
} else {
|
||
alert('箱子信息出错,保存失败!');
|
||
return;
|
||
}
|
||
}
|
||
|
||
var deleteRowsjson = app.jsonToString(subdata1);
|
||
subdelvalue.push(deleteRowsjson);
|
||
subinsertvalue.push(insertRowsjson);
|
||
subupdatevalue.push(updateRowsjson);
|
||
////////////////////////
|
||
|
||
////////////////////////////////////////////////
|
||
var rows = [];
|
||
var insertRows = [];
|
||
var updateRows = [];
|
||
var varupdateRows = [];
|
||
|
||
let deletedRows = delSubgridRows.map(row => ({ subid: row.subid }));
|
||
|
||
subdelvalue.push(app.jsonToString(deletedRows));
|
||
|
||
rows = subgridRows;
|
||
irow = rows.length;
|
||
var serverrows = getserversubdata('v_xg_buyin_sub', strid);
|
||
|
||
for (i = 0; i < irow; i++) {
|
||
var conkeyid = rows[i].mx_keyid; //v_xg_constate
|
||
rows[i].mx_xh = i + 1;
|
||
rows[i].mx_type = "买箱入库";
|
||
// rows[i].mx_date=$("#b_date").val();
|
||
let date = $("#b_date").val();
|
||
|
||
if (date && !isNaN(Date.parse(date))) {
|
||
let d = new Date(date);
|
||
rows[i].mx_date = d.toISOString().slice(0, 10);
|
||
}
|
||
|
||
rows[i].mx_dw_id = $("#b_customer_id").val();
|
||
rows[i].mx_mycompany_id = $("#b_mycompany_id").val();
|
||
rows[i].father = strid;
|
||
};
|
||
|
||
/*var connoArray=[];
|
||
var Fsql=" mx_type not in('卖箱出库','还箱退租','代管出库')"
|
||
if (strid!=''){
|
||
Fsql=Fsql+" and father<>'"+strid+"'";
|
||
}
|
||
var tmpjson=loaddatas('xg_conmaxtype', Fsql, '', '');
|
||
for(var k in tmpjson){
|
||
if (!(strinArray(connoArray,tmpjson[k].mx_conno))){
|
||
connoArray.push(tmpjson[k].mx_conno);
|
||
}
|
||
} */
|
||
|
||
var xgcwvalue = "";
|
||
var cwrows = [];
|
||
var searchsqlcw = " father ='" + strid + "' " + " and (isnull(mx_keyid,'')='') "
|
||
//alert(searchsqlcw);
|
||
var xgcwrows = loaddatas('xg_cw', searchsqlcw, 'subid', '');
|
||
// 收集需要检查的箱号
|
||
var connoCheckList = [];
|
||
for (var i = 0; i < irow; i++) {
|
||
var row = rows[i];
|
||
if (row.subid !== undefined && row.mx_keyid && row.mx_conno && row.v_checkyx !== '是') {
|
||
connoCheckList.push(row.mx_conno);
|
||
}
|
||
}
|
||
|
||
// 批量查询箱池,分批处理
|
||
var existingConnosMap = {};
|
||
var batchSize = 1000;
|
||
for (var start = 0; start < connoCheckList.length; start += batchSize) {
|
||
var batchList = connoCheckList.slice(start, start + batchSize);
|
||
|
||
var sql = "father<>'" + strid + "' and mx_conno in ('" + batchList.join("','") + "') and mx_type not in('卖箱出库','还箱退租','代管出库')";
|
||
|
||
var tmpjson3 = loaddatas('xg_conmaxtype', sql, '', '');
|
||
|
||
tmpjson3.forEach(item => existingConnosMap[item.mx_conno] = true);
|
||
}
|
||
|
||
|
||
// 循环处理每行
|
||
for (var i = 0; i < irow; i++) {
|
||
var row = rows[i];
|
||
var conkeyid = row.mx_keyid;
|
||
|
||
if (row.subid === undefined) {
|
||
insertRows.push(row);
|
||
continue;
|
||
}
|
||
|
||
if (conkeyid && row.mx_conno && row.v_checkyx !== '是') {
|
||
if (existingConnosMap[row.mx_conno]) {
|
||
alert('箱号:' + row.mx_conno + '在箱池中已经存在,不可重复输入!');
|
||
continue;
|
||
}
|
||
}
|
||
|
||
if (row.v_checkyx === '是') continue;
|
||
|
||
updateRows.push(row);
|
||
|
||
if (conkeyid) continue;
|
||
|
||
// 填充 cwrows
|
||
var Fconno = row.mx_conno || '';
|
||
var contype = row.mx_contype || '';
|
||
var txid = row.mx_txid || '';
|
||
var xk = row.mx_xk || '';
|
||
var atwhere = row.mx_atwhere || '';
|
||
var txdate = row.mx_zxdate || '';
|
||
|
||
var subid = row.subid;
|
||
var ssubid = subid.replace('{', '').replace('}', '');
|
||
if (xgcwrows.length > 0) {
|
||
for (var m in xgcwrows) {
|
||
var Flinkfdid = xgcwrows[m].mx_linkfd_id;
|
||
if (Flinkfdid === subid || Flinkfdid === ssubid) {
|
||
|
||
let obj = {}; // 最终只 push 变化的字段
|
||
const old = xgcwrows[m]; // 原值对象
|
||
|
||
// 比较的字段列表
|
||
const compareList = [
|
||
['mx_conno', Fconno],
|
||
['mx_contype', contype],
|
||
['mx_txid', txid],
|
||
['mx_xk', xk],
|
||
['mx_atwhere', atwhere],
|
||
['mx_txdate', txdate]
|
||
];
|
||
|
||
// 遍历每个字段,判断是否变化
|
||
compareList.forEach(([field, newVal]) => {
|
||
if (old[field] !== newVal) {
|
||
obj[field] = newVal;
|
||
}
|
||
});
|
||
|
||
// subid 必须带上(用于后端定位记录)
|
||
obj.subid = old.subid;
|
||
|
||
// 只有有变化才 push(防止无意义更新)
|
||
if (Object.keys(obj).length > 1) {
|
||
cwrows.push(obj);
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
insertRowsjson = '';
|
||
insertRowsjson = app.jsonToString(insertRows);
|
||
subinsertvalue.push(insertRowsjson);
|
||
|
||
updateRowsjson = '';
|
||
updateRowsjson = getSubModifiedJson(eval('(' + subgridjson + ')'), updateRows)
|
||
subupdatevalue.push(updateRowsjson);
|
||
|
||
//////判断是否保存冲突////////
|
||
if (updateRowsjson != '[]') {
|
||
var updatedata = getSubModifiedJson(eval('(' + subgridjson + ')'), serverrows)
|
||
if (updatedata != '[]') {
|
||
alert('箱子信息冲突,保存失败!');
|
||
loaddata_detail_sub('subgrid', 'v_xg_buyin_sub', strid, '');
|
||
return;
|
||
}
|
||
}
|
||
|
||
//alert(updateRowsjson);
|
||
|
||
|
||
/////////////修改财务箱号//////////
|
||
insertRowsjson = '[]';
|
||
updateRowsjson = '[]';
|
||
deleteRowsjson = '[]';
|
||
updateRowsjson = app.jsonToString(cwrows);
|
||
//alert(updateRowsjson);
|
||
subdelvalue.push(deleteRowsjson);
|
||
subinsertvalue.push(insertRowsjson);
|
||
subupdatevalue.push(updateRowsjson);
|
||
//subupdatevalue.push(app.jsonToString(rows1));
|
||
/////////////////
|
||
var sResult = '';
|
||
console.log(subtable);
|
||
console.log(subinsertvalue);
|
||
console.log(subdelvalue);
|
||
console.log(subupdatevalue);
|
||
console.log(keyid);
|
||
|
||
|
||
sResult = saveobjt(subtable, subinsertvalue, subdelvalue, subupdatevalue, keyid);
|
||
|
||
|
||
if (sResult == 'OK') {
|
||
$('#b_id').attr({ readonly: 'readonly' });
|
||
alert('保存成功!');
|
||
setywwcqty();
|
||
if (getfieldvaluebyid('xg_buyin', 'b_sh', 'b_id', strid) == '1') {
|
||
if (getfieldvaluebyid('s_keyvalue', 'b_value', 'b_key', 'syslog') == '1') {
|
||
$("#subgrid").datagrid("acceptChanges");
|
||
rows = subgridRows;
|
||
savesubLog(eval('(' + subgridjson + ')'), rows, strid, '箱号:'); //
|
||
}
|
||
}
|
||
loaddata('buyinform', 'v_xg_buyin', strid, 'main');
|
||
var formobj = app.serializeObject2($('#buyinform'));
|
||
delete formobj["bcheck"];
|
||
oldformjson = app.jsonToString(formobj);
|
||
loaddata_detail_sub('subgrid', 'v_xg_buyin_sub', strid, '');
|
||
} else {
|
||
alert(sResult);
|
||
}
|
||
return sResult;
|
||
}
|
||
|
||
function updatecondata(Fname) {
|
||
var Fieldname = '';
|
||
var Fieldname_mx = '';
|
||
|
||
if (Fname == '箱型') {
|
||
Fieldname = 'b_contype';
|
||
Fieldname_mx = 'mx_contype';
|
||
}
|
||
if (Fname == '箱况') {
|
||
Fieldname = 'b_xk';
|
||
Fieldname_mx = 'mx_xk';
|
||
}
|
||
if (Fname == '提箱单号') {
|
||
Fieldname = 'b_txid';
|
||
Fieldname_mx = 'mx_txid';
|
||
}
|
||
if (Fname == '存放堆场') {
|
||
Fieldname = 'b_atwhere';
|
||
Fieldname_mx = 'mx_atwhere';
|
||
}
|
||
|
||
// 校验是否为空
|
||
if ($('#' + Fieldname).val() == '') {
|
||
alert(Fname + '不能为空,请检查!');
|
||
return;
|
||
}
|
||
|
||
// 必须先结束编辑才能进行 loadData
|
||
if (!endEditing_sub()) {
|
||
return;
|
||
}
|
||
|
||
var newvalue = $('#' + Fieldname).val();
|
||
var newname = $('#v_b_atwhere_name').val(); // 只用于存放堆场
|
||
|
||
// 批量更新 rows
|
||
for (var i = 0; i < subgridRows.length; i++) {
|
||
|
||
// 跳过已验箱的数据
|
||
if (subgridRows[i].v_checkyx == '是') continue;
|
||
|
||
subgridRows[i][Fieldname_mx] = newvalue;
|
||
|
||
if (Fname == '存放堆场') {
|
||
subgridRows[i]['v_mx_atwhere_name'] = newname;
|
||
}
|
||
}
|
||
|
||
$('#subgrid').datagrid('loadData', subgridRows);
|
||
}
|
||
|
||
function savesubLog(oldjsons, newjsons, recordID, type) {
|
||
// alert(recordID);
|
||
var i, j;
|
||
var oldjson, newjson
|
||
var tmps;
|
||
var supdated = '';
|
||
var sdeleted = '';
|
||
|
||
var sresult = '';
|
||
for (i = 0; i <= oldjsons.length - 1; i++) {
|
||
oldjson = oldjsons[i];
|
||
var finded = false;
|
||
var subid = oldjson['subid'];
|
||
subid = "{" + subid + "}";
|
||
//alert(subid);
|
||
for (j = 0; j <= newjsons.length - 1; j++) {
|
||
if (newjsons[j]['subid'] == oldjson['subid']) {
|
||
// alert("122");
|
||
var strMainUpdate = '';
|
||
var Modifyb = '';
|
||
var Modifyh = '';
|
||
/*if(newjsons[j]['mx_conno'] !=oldjson['mx_conno']){
|
||
strMainUpdate=strMainUpdate+"箱号:"+oldjson['mx_conno']+"-->"+newjsons[j]['mx_conno']+'; ';
|
||
Modifyb = Modifyb + "箱号:" + oldjson['mx_conno'] + '; ';
|
||
Modifyh = Modifyh + newjsons[j]['mx_conno'] + '; ';
|
||
}*/
|
||
|
||
if (newjsons[j]['mx_contype'] != oldjson['mx_contype']) {
|
||
strMainUpdate = strMainUpdate + ";箱型:" + oldjson['mx_contype'] + "-->" + newjsons[j]['mx_contype'] + '; ';
|
||
Modifyb = Modifyb + ";箱型:" + oldjson['mx_contype'] + '; ';
|
||
Modifyh = Modifyh + ";箱型:" + newjsons[j]['mx_contype'] + '; ';
|
||
}
|
||
|
||
if (newjsons[j]['mx_xk'] != oldjson['mx_xk']) {
|
||
strMainUpdate = strMainUpdate + ";箱况:" + oldjson['mx_xk'] + "-->" + newjsons[j]['mx_xk'] + '; ';
|
||
Modifyb = Modifyb + ";箱况:" + oldjson['mx_xk'] + '; ';
|
||
Modifyh = Modifyh + ";箱况:" + newjsons[j]['mx_xk'] + '; ';
|
||
}
|
||
|
||
if (newjsons[j]['mx_ccdate'] != oldjson['mx_ccdate']) {
|
||
strMainUpdate = strMainUpdate + ";制造日期:" + oldjson['mx_ccdate'] + "-->" + newjsons[j]['mx_ccdate'] + '; ';
|
||
Modifyb = Modifyb + ";制造日期:" + oldjson['mx_ccdate'] + '; ';
|
||
Modifyh = Modifyh + ";制造日期:" + newjsons[j]['mx_ccdate'] + '; ';
|
||
}
|
||
|
||
if (newjsons[j]['mx_txid'] != oldjson['mx_txid']) {
|
||
strMainUpdate = strMainUpdate + " ;提箱单号:" + oldjson['mx_txid'] + "-->" + newjsons[j]['mx_txid'] + '; ';
|
||
Modifyb = Modifyb + " ;提箱单号:" + oldjson['mx_txid'] + '; ';
|
||
Modifyh = Modifyh + " ;提箱单号:" + newjsons[j]['mx_txid'] + '; ';
|
||
}
|
||
|
||
if (newjsons[j]['mx_atwhere'] != oldjson['mx_atwhere']) {
|
||
strMainUpdate = strMainUpdate + " ;存放堆场:" + oldjson['v_mx_atwhere_name'] + "-->" + newjsons[j]['v_mx_atwhere_name'] + '; ';
|
||
Modifyb = Modifyb + " ;存放堆场:" + oldjson['v_mx_atwhere_name'] + '; ';
|
||
Modifyh = Modifyh + " ;存放堆场:" + newjsons[j]['v_mx_atwhere_name'] + '; ';
|
||
}
|
||
|
||
|
||
if (newjsons[j]['mx_zxdate'] != oldjson['mx_zxdate']) {
|
||
strMainUpdate = strMainUpdate + " ;进场日期:" + oldjson['mx_zxdate'] + "-->" + newjsons[j]['mx_zxdate'] + '; ';
|
||
Modifyb = Modifyb + " ;进场日期:" + oldjson['mx_zxdate'] + '; ';
|
||
Modifyh = Modifyh + " ;进场日期:" + newjsons[j]['mx_zxdate'] + '; ';
|
||
}
|
||
|
||
/* if(newjsons[j]['mx_city_id']!= oldjson['mx_city_id']){
|
||
strMainUpdate=strMainUpdate+" ;还箱城市:"+oldjson['v_mx_cityoutname']+"-->"+newjsons[j]['v_mx_cityoutname']+'; ';
|
||
Modifyb=Modifyb+" ;还箱城市:"+oldjson['v_mx_cityoutname']+'; ';
|
||
Modifyh=Modifyh+" ;还箱城市:"+newjsons[j]['v_mx_cityoutname']+'; ';
|
||
}
|
||
|
||
if(newjsons[j]['mx_atwhere_hx']!= oldjson['mx_atwhere_hx']){
|
||
strMainUpdate=strMainUpdate+" ;还箱堆场:"+oldjson['v_mx_atwhere_name_hx']+"-->"+newjsons[j]['v_mx_atwhere_name_hx']+'; ';
|
||
Modifyb=Modifyb+" ;还箱堆场:"+oldjson['v_mx_atwhere_name_hx']+'; ';
|
||
Modifyh=Modifyh+" ;还箱堆场:"+newjsons[j]['v_mx_atwhere_name_hx']+'; ';
|
||
}*/
|
||
|
||
if (newjsons[j]['mx_bz'] != oldjson['mx_bz']) {
|
||
strMainUpdate = strMainUpdate + " ;备注:" + oldjson['mx_bz'] + "-->" + newjsons[j]['mx_bz'] + '; ';
|
||
Modifyb = Modifyb + " ;备注:" + oldjson['mx_bz'] + '; ';
|
||
Modifyh = Modifyh + " ;备注:" + newjsons[j]['mx_bz'] + '; ';
|
||
}
|
||
|
||
|
||
|
||
if (strMainUpdate != '') {
|
||
/* var feetype=oldjson['v_mx_feetype_name'];
|
||
strMainUpdate=type+feetype+" " +strMainUpdate;
|
||
var Fuser=getfieldvaluebyid("b_user","b_name","b_id",userid);
|
||
Modifyh=Modifyh+newjsons[j]['mx_inputdate']+'; '+Fuser+': ';
|
||
Modifyb=Modifyb+oldjson['mx_inputdate']+'; '+oldjson['v_mx_inputman_name']+': ';*/
|
||
//alert(strMainUpdate);
|
||
var conno = oldjson['mx_conno'];
|
||
strMainUpdate = type + oldjson['mx_conno'] + "-->" + newjsons[j]['mx_conno'] + '; ' + strMainUpdate;
|
||
Modifyh = type + newjsons[j]['mx_conno'] + " " + Modifyh;
|
||
Modifyb = type + oldjson['mx_conno'] + " " + Modifyb;
|
||
saveLog('xg_buyin', strMainUpdate, "", "[]", "[]", "[]", recordID, subid, Modifyb, Modifyh);
|
||
} else if (newjsons[j]['mx_conno'] != oldjson['mx_conno']) {
|
||
strMainUpdate = type + oldjson['mx_conno'] + "-->" + newjsons[j]['mx_conno'] + '; ';
|
||
Modifyb = type + oldjson['mx_conno'] + '; ';
|
||
Modifyh = type + newjsons[j]['mx_conno'] + '; ';
|
||
saveLog('xg_buyin', strMainUpdate, "", "[]", "[]", "[]", recordID, subid, Modifyb, Modifyh);
|
||
}
|
||
finded = true;
|
||
break;
|
||
}
|
||
}
|
||
if (!finded) {
|
||
//alert("11")
|
||
var conno = oldjson['mx_conno'];
|
||
var contype = oldjson['mx_contype'];
|
||
var atwhere = oldjson['v_mx_atwhere_name'];
|
||
var strMainDelete = type + conno + ";箱型:" + contype + atwhere;
|
||
var strMainDelete = "删除" + type + conno + ";箱型:" + contype + " ;提箱堆场:" + atwhere + "!"
|
||
saveLog('xg_buyin', "", strMainDelete, "[]", "[]", "[]", recordID, subid, "", "");
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
function setywwcqty() {
|
||
var strid = $("#b_id").val();
|
||
var stridval = "买箱入库";
|
||
stridval = stridval + "," + strid;
|
||
var resdata = ExecProcedure('p_update_xgwcqty', { stridarr: stridval });
|
||
}
|
||
|
||
|
||
function showattach1() {
|
||
var strid = $("#b_id").val();
|
||
var iread = '0';
|
||
if ($('#btn_save').attr('disabled') == 'disabled') {
|
||
iread = '1';
|
||
}
|
||
if (document.getElementById("b_id").readOnly) {
|
||
} else {
|
||
alert('请先保存数据');
|
||
return;
|
||
}
|
||
getattachfile(strid, 'xg_buyin_files', iread);
|
||
}
|
||
|
||
|
||
function showattach() {
|
||
if (strid == "") { return; }
|
||
parent.$('<div/>').dialog({
|
||
title: '箱证管理' + strid,
|
||
width: 540,
|
||
height: 320,
|
||
cache: false,
|
||
onClose: function () {
|
||
$(this).remove();
|
||
},
|
||
top: 90,
|
||
content: '<iframe id="dialogattach" name="dialogattach" src="'
|
||
+ 'jbusiness/attachfile.jsp?id=' + strid + '&viewname=xg_containerlib_files'
|
||
+ '" allowTransparency="true" scrolling="auto" width="100%" height="99.2%" frameBorder="0" name=""></iframe>',
|
||
modal: true
|
||
});
|
||
}
|
||
|
||
function b_customer_idChange() {
|
||
if ($("#b_customer_id").val() == "") {
|
||
$("#v_customer_name").val('');
|
||
} else {
|
||
var s = getfieldvaluebyid('b_othercompany', 'b_name', 'b_id', $("#b_customer_id").val());
|
||
$("#v_customer_name").val(s);
|
||
}
|
||
}
|
||
|
||
function b_atwhereChange() {
|
||
if ($("#b_atwhere").val() == "") {
|
||
$("#v_b_atwhere_name").val('');
|
||
} else {
|
||
var s = getfieldvaluebyid('b_othercompany', 'b_name', 'b_id', $("#b_atwhere").val());
|
||
$("#v_b_atwhere_name").val(s);
|
||
}
|
||
}
|
||
|
||
|
||
function b_customer_idChange() {
|
||
if ($("#b_customer_id").val() == "") {
|
||
$("#v_customer_name").val('');
|
||
$("#v_customer_linkman_ch").val('');
|
||
// custid='';
|
||
|
||
} else {
|
||
var s = getfieldvaluebyid('b_othercompany', 'b_name', 'b_id', $("#b_customer_id").val());
|
||
$("#v_customer_name").val(s);
|
||
var s = getfieldvaluebyid('b_contact', 'b_name_ch', 'b_customer_id', $("#b_customer_id").val());
|
||
$("#v_customer_linkman_ch").val(s);
|
||
// var s=getfieldvaluebyid('b_contact', 'b_', 'b_phone',s);
|
||
//$("#b_custlinkman_phone").val(s);
|
||
// custid=$("#b_customer_id").val();
|
||
}
|
||
}
|
||
|
||
function v_customer_linkman_chChange() {
|
||
// alert('11');
|
||
if ($("#v_customer_linkman_ch").val() == "") {
|
||
$("#b_custlinkman_id").val('');
|
||
// $("#b_custlinkman_phone").val('');
|
||
} else {
|
||
var s = getfieldvaluebyid('b_contact', 'b_id', 'b_name_ch', $("#v_customer_linkman_ch").val());
|
||
$("#b_custlinkman_id").val(s);
|
||
// var s=getfieldvaluebyid('b_contact', 'b_phone', 'b_name_ch',$("#v_customer_linkman_ch").val());
|
||
// $("#b_custlinkman_phone").val(s);
|
||
}
|
||
}
|
||
|
||
|
||
function v_ownernameChange() {
|
||
if ($("#v_ownername").val() == "") {
|
||
$("#b_owner_id").val('');
|
||
} else {
|
||
var s = getfieldvaluebyid('b_user', 'b_id', 'b_name', $("#v_ownername").val());
|
||
$("#b_owner_id").val(s);
|
||
}
|
||
}
|
||
|
||
function v_moneynameChange() {
|
||
// thischanged='1';
|
||
if ($("#v_moneyname").val() == "") {
|
||
$("#b_money_id").val('');
|
||
}
|
||
}
|
||
|
||
function v_sales_nameChange() {
|
||
if ($("#v_sales_name").val() == "") {
|
||
$("#b_sales_id").val('');
|
||
} else {
|
||
var s = getfieldvaluebyid('b_user', 'b_id', 'b_name', $("#v_sales_name").val());
|
||
$("#b_sales_id").val(s);
|
||
}
|
||
}
|
||
|
||
function b_mycompany_idChange() {
|
||
if ($("#b_mycompany_id").val() == "") {
|
||
$("#v_company_name").val('');
|
||
} else {
|
||
var s = getfieldvaluebyid('b_othercompany', 'b_name', 'b_id', $("#b_mycompany_id").val());
|
||
$("#v_company_name").val(s);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
jQuery_1_2_6("document").ready(function () {
|
||
|
||
setAutoCompleteSimple('#b_xz', [["是"], ["否"]]);
|
||
|
||
setAutoComplete('#b_supply_id', 'v_b_othercompany_shipcompany', 'b_id', 'b_name', '');
|
||
jQuery_1_2_6("#b_supply_id").result(function (event, data, formatted) {
|
||
if (data) {
|
||
$("#v_supply_name").val(data.b_name);
|
||
}
|
||
});
|
||
|
||
setAutoComplete('#b_mycompany_id', 'v_b_othercompany_my', 'b_id', 'b_name', '');
|
||
jQuery_1_2_6("#b_mycompany_id").result(function (event, data, formatted) {
|
||
if (data)
|
||
$("#v_company_name").val(data.b_name);
|
||
});
|
||
|
||
setAutoCompleteEx('#v_sales_name', 'b_user', 'b_name', 'b_id', "b_salesman='1'", '');
|
||
jQuery_1_2_6("#v_sales_name").result(function (event, data, formatted) {
|
||
if (data)
|
||
$("#b_sales_id").val(data.b_id);
|
||
});
|
||
|
||
setAutoComplete('#b_contype', 'b_con_type', 'b_name', 'b_id', '');
|
||
setAutoComplete('#b_xk', 'b_xiangkuang', 'b_name', 'b_id', '');
|
||
setAutoComplete('#b_ywtype', 'b_ywtype_xg', 'b_name', 'b_id', '');
|
||
|
||
setAutoComplete('#b_atwhere', 'v_b_othercompany_duichang', 'b_id', 'b_name', '');
|
||
jQuery_1_2_6('#b_atwhere').result(function (event, data, formatted) {
|
||
if (data) {
|
||
$('#v_b_atwhere_name').val(data.b_name);
|
||
$('#v_b_atwhere_addr').val(data.b_addr);
|
||
$('#v_cityname').val(data.v_city_name);
|
||
$('#b_city_id').val(data.b_city_id);
|
||
}
|
||
});
|
||
setAutoComplete('#v_cityname', 'b_city', 'b_name_c', 'b_id', '');
|
||
jQuery_1_2_6('#v_cityname').result(function (event, data, formatted) {
|
||
if (data) {
|
||
$('#b_city_id').val(data.b_id);
|
||
}
|
||
});
|
||
setAutoComplete('#v_ownername', 'b_user', 'b_name', 'b_id', '');
|
||
jQuery_1_2_6("#v_ownername").result(function (event, data, formatted) {
|
||
if (data)
|
||
$("#b_owner_id").val(data.b_id);
|
||
});
|
||
|
||
setAutoComplete_moneytype('#b_money_id', 'b_money', 'b_name', 'b_id', '');
|
||
/*jQuery_1_2_6("#v_moneyname").result(function(event, data, formatted){
|
||
if (data){
|
||
$("#b_money_id").val(data.b_id);
|
||
//var exrate=getfieldvaluebyid('b_money', 'b_hl', 'b_id', data.b_id);
|
||
// $("#b_exrate").val(exrate);
|
||
}
|
||
});*/
|
||
|
||
setAutoComplete_moneytype('#b_fktk', 'b_othercompany_type_3', 'b_name', 'b_id', '');
|
||
setAutoComplete_moneytype('#b_payment', 'b_payment', 'b_name', 'b_id', '');
|
||
setAutoComplete('#b_customer_id', 'v_b_othercompany_xy', 'b_id', 'b_name', '');
|
||
jQuery_1_2_6("#b_customer_id").result(function (event, data, formatted) {
|
||
if (data) {
|
||
$("#v_customer_name").val(data.b_name);
|
||
var type3 = getfieldvaluebyid('v_b_othercompany', 'v_type3_name', 'b_id', data.b_id);
|
||
$("#b_fktk").val(type3);
|
||
var payment = getfieldvaluebyid('b_othercompany', 'b_payment', 'b_id', data.b_id);
|
||
$("#b_payment").val(payment);
|
||
|
||
|
||
}
|
||
});
|
||
})
|
||
|
||
|
||
function checkchange() {
|
||
//endEditing_fee();
|
||
endEditing_sub();
|
||
if ($('#btn_save').attr('disabled') == 'disabled') {
|
||
return false;
|
||
}
|
||
var formobj = app.serializeObject2($('#buyinform'));
|
||
delete formobj["bcheck"];
|
||
|
||
newformjson = app.jsonToString(formobj);
|
||
newsubgridjson = app.jsonToString(subgridRows);
|
||
|
||
if (newformjson != oldformjson || newsubgridjson != subgridjson) { //||newgridjson!=feegridjson
|
||
//alert('111');
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
//////////////////////
|
||
var editIndex_fee = undefined;
|
||
function endEditing_fee() {
|
||
if (editIndex_fee == undefined) {
|
||
return true
|
||
}
|
||
if ($('#feegrid').datagrid('validateRow', editIndex_fee)) {
|
||
$('#feegrid').datagrid('endEdit', editIndex_fee);
|
||
editIndex_fee = undefined;
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
var editIndex_sub = undefined;
|
||
|
||
function endEditing_sub() {
|
||
if (editIndex_sub == undefined) {
|
||
return true
|
||
}
|
||
if ($('#subgrid').datagrid('validateRow', editIndex_sub)) {
|
||
$('#subgrid').datagrid('endEdit', editIndex_sub);
|
||
editIndex_sub = undefined;
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
function setAutoComplete_moneytype(comboname, viewname, field1, field2, userid) {
|
||
jQuery_1_2_6(comboname).unautocomplete();
|
||
jQuery_1_2_6(comboname).autocomplete('jsp/getAutocompleteData.jsp', {
|
||
minChars: 0,
|
||
width: 250,
|
||
max: 11,
|
||
matchContains: true,
|
||
mustMatch: true,
|
||
extraParams: {
|
||
viewname: viewname,
|
||
field1: field1,
|
||
field2: field2,
|
||
userid: userid
|
||
},
|
||
dataType: "json",
|
||
matchSubset: false,
|
||
|
||
parse: function (data) {
|
||
var rows = data.rows;
|
||
return $.map(rows, function (row) {
|
||
return {
|
||
data: row,
|
||
value: row[field1],
|
||
result: row[field1]
|
||
}
|
||
});
|
||
},
|
||
formatItem: function (item) {// 显示下拉列表的内容
|
||
return "<div>" + item[field1] + "|" + item[field2]
|
||
+ "</div>";
|
||
},
|
||
formatMatch: function (item) {
|
||
return item[field1];
|
||
},
|
||
formatResult: function (item) {
|
||
return item[field1];
|
||
}
|
||
})
|
||
}
|
||
|
||
|
||
function getfocusedcol(grid) {
|
||
if (editIndex_fee != undefined) {
|
||
var editor;
|
||
for (var j = 0; j < columnarray.length; j++) {
|
||
editor = grid.datagrid('getEditor',
|
||
{
|
||
index: editIndex_fee,
|
||
field: columnarray[j]
|
||
}
|
||
);
|
||
if (editor) {
|
||
if (editor.target.is(":focus")) {
|
||
fieldname = columnarray[j];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
function onBeginEdit_sub(index, row) {
|
||
setEditing_sub(index);
|
||
}
|
||
function setEditing_sub(rowIndex) {
|
||
//alert('bbb');
|
||
//$('#subgrid').datagrid('getEditor', {index: rowIndex, field:'v_mx_atwhere_addr'}).target.attr("readonly","readonly");
|
||
// $('#subgrid').datagrid('getEditor', {index: rowIndex, field:''}).target.attr("readonly","readonly");
|
||
|
||
//$('#subgrid').datagrid('getEditor', {index: rowIndex, field:'v_mx_dw_name'}).target.attr("readonly","readonly");
|
||
}
|
||
function onBeginEdit_fee(index, row) {
|
||
var editor_sh = $('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_sh'
|
||
});/*
|
||
if (editor_sh.target.prop("checked")){
|
||
if ((canedit=='0')||(feeshqx!='1')){
|
||
$('#feegrid').datagrid('endEdit',index);
|
||
return;
|
||
}
|
||
|
||
}*/
|
||
|
||
if (feeshqx != '1') {
|
||
editor_sh.target.bind('click', function () {
|
||
return false;
|
||
});
|
||
} else {
|
||
editor_sh.target.bind('change', function () {
|
||
if (!editor_sh.target.prop("checked")) {
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_sh'
|
||
}).target.prop("checked", false);
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_sh'
|
||
}).target.val('0');
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_shman_id'
|
||
}).target.val('');
|
||
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_shdate'
|
||
}).target.val('');
|
||
} else {
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_sh'
|
||
}).target.prop("checked", true);
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_sh'
|
||
}).target.val('1');
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_shman_id'
|
||
}).target.val(userid);
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_shdate'
|
||
}).target.val(getnowdate());
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_dw_id'
|
||
}).target.bind('change', function () {
|
||
var editdwid = $('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_dw_id'
|
||
});
|
||
var editdwname = $('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'v_mx_dw_name'
|
||
});
|
||
if (editdwid.target.val() == "") {
|
||
editdwname.target.val('');
|
||
} else {
|
||
var s = getfieldvaluebyid('b_othercompany', 'b_name', 'b_id', editdwid.target.val());
|
||
editdwname.target.val(s);
|
||
//row.v_mx_dw_name=s;
|
||
}
|
||
});
|
||
setEditing(index);
|
||
}
|
||
|
||
|
||
function setEditing(rowIndex) {
|
||
columnarray = getVisibleColumn('feegrid');
|
||
//alert('1111111');
|
||
//$('#feegrid').datagrid('getEditor', {index: rowIndex, field:'mx_sh'}).target.prop("disabled",true);
|
||
$('#feegrid').datagrid('getEditor', { index: rowIndex, field: 'mx_amount_root' }).target.attr("readonly", "readonly");
|
||
$('#feegrid').datagrid('getEditor', { index: rowIndex, field: 'v_mx_dw_name' }).target.attr("readonly", "readonly");
|
||
$('#feegrid').datagrid('getEditor', { index: rowIndex, field: 'mx_amount' }).target.attr("readonly", "readonly");
|
||
$('#feegrid').datagrid('getEditor', { index: rowIndex, field: 'mx_shman_id' }).target.attr("readonly", "readonly");
|
||
$('#feegrid').datagrid('getEditor', { index: rowIndex, field: 'mx_shdate' }).target.attr("readonly", "readonly");
|
||
//var editors = $('#feegrid').datagrid('getEditors', rowIndex);
|
||
var priceEditor = $('#feegrid').datagrid('getEditor', {
|
||
index: rowIndex,
|
||
field: 'mx_price'
|
||
});
|
||
|
||
var qtyEditor = $('#feegrid').datagrid('getEditor', {
|
||
index: rowIndex,
|
||
field: 'mx_qty'
|
||
});
|
||
var amountEditor = $('#feegrid').datagrid('getEditor', {
|
||
index: rowIndex,
|
||
field: 'mx_amount_root'
|
||
});
|
||
var exrateEditor = $('#feegrid').datagrid('getEditor', {
|
||
index: rowIndex,
|
||
field: 'mx_exrate'
|
||
});
|
||
var amountrmbEditor = $('#feegrid').datagrid('getEditor', {
|
||
index: rowIndex,
|
||
field: 'mx_amount'
|
||
});
|
||
priceEditor.target.bind('change', function () {
|
||
calculate();
|
||
});
|
||
qtyEditor.target.bind('change', function () {
|
||
calculate();
|
||
});
|
||
exrateEditor.target.bind('change', function () {
|
||
calculate();
|
||
});
|
||
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: rowIndex,
|
||
field: 'mx_invoiceno'
|
||
}).target.bind('change', function () {
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: rowIndex,
|
||
field: 'mx_invoicedate'
|
||
}).target.val($(this).val() ? getnowdate() : '');
|
||
});
|
||
|
||
function calculate() {
|
||
//alert('calculate');
|
||
var strprice = priceEditor.target.val();
|
||
//strprice=strprice.replace(/(^\s*)|(\s*$)/g, '');
|
||
var strqty = qtyEditor.target.val();
|
||
//strqty=strqty.replace(/(^\s*)|(\s*$)/g, '');
|
||
var x = /^(\+|-)?\d+($|\.\d+$)/;
|
||
if (!x.test(strprice)) {
|
||
//priceEditor.target.val('0');
|
||
strprice = 0;
|
||
priceEditor.target.val(0);
|
||
}
|
||
if (!x.test(strqty)) {
|
||
//qtyEditor.target.val('0');
|
||
strqty = 0;
|
||
qtyEditor.target.val(0);
|
||
}
|
||
var cost = strprice * strqty;
|
||
amountEditor.target.val(cost);
|
||
var amountrmb = cost * exrateEditor.target.val();
|
||
amountrmbEditor.target.val(amountrmb);
|
||
calcw();
|
||
}
|
||
}
|
||
|
||
|
||
function calcw() {
|
||
var t_ysrmb = 0, t_ysusd = 0, ysrmb = 0, ysusd = 0, sel_srmb = 0, sel_susd = 0;
|
||
var t_yfrmb = 0, t_yfusd = 0, yfrmb = 0, yfusd = 0, sel_frmb = 0, sel_fusd = 0;
|
||
|
||
var moneyArray = [];
|
||
var data = $('#feegrid').datagrid('getRows');
|
||
var amount_ze_ys = 0;
|
||
var amount_ze_yf = 0;
|
||
var amount_tax_ys = 0;
|
||
var amount_tax_yf = 0;
|
||
for (i in data) {
|
||
var amount_ys = 0;
|
||
var amount_yf = 0;
|
||
canadd = true;
|
||
if (data[i].mx_type_id == '应收') {
|
||
amount_ys = Number(data[i].mx_amount_root);
|
||
amount_ze_ys = Number(amount_ze_ys) + Number(data[i].mx_amount);
|
||
// amount_tax_ys=Number(amount_tax_ys)+Number(data[i].v_ivtaxamount);
|
||
}
|
||
if (data[i].mx_type_id == '应付') {
|
||
amount_yf = Number(data[i].mx_amount_root);
|
||
amount_ze_yf = Number(amount_ze_yf) + Number(data[i].mx_amount);
|
||
// amount_tax_yf=Number(amount_tax_yf)+Number(data[i].v_ivtaxamount);
|
||
}
|
||
for (var k in moneyArray) {
|
||
if (moneyArray[k].moneyname == data[i].mx_moneytype_id) {
|
||
moneyArray[k].amount_ys = moneyArray[k].amount_ys + amount_ys;
|
||
moneyArray[k].amount_yf = moneyArray[k].amount_yf + amount_yf;
|
||
var canadd = false;
|
||
}
|
||
}
|
||
if (canadd) {
|
||
if (data[i].mx_moneytype_id != '') {
|
||
moneyArray.push({
|
||
moneyname: data[i].mx_moneytype_id,
|
||
// v_moneyname: data[i].v_mx_moneytype_name,
|
||
amount_ys: amount_ys,
|
||
amount_yf: amount_yf,
|
||
})
|
||
}
|
||
}
|
||
}
|
||
var tmp_ys_total = '';
|
||
var tmp_yf_total = '';
|
||
var tmp_ys_dz = '';
|
||
var tmp_yf_dz = '';
|
||
var tmp_ys_sel = '';
|
||
var tmp_yf_sel = '';
|
||
var tmp_zd_total_c = '';
|
||
//=====数组排序------
|
||
for (var j = 0; j < moneyArray.length - 1; j++) {
|
||
//两两比较,如果前一个比后一个大,则交换位置。
|
||
for (var i = 0; i < moneyArray.length - 1 - j; i++) {
|
||
var beginstr = moneyArray[i].moneyname;
|
||
var laststr = moneyArray[i + 1].moneyname;
|
||
if (beginstr > laststr) {
|
||
var temp = moneyArray[i];
|
||
moneyArray[i] = moneyArray[i + 1];
|
||
moneyArray[i + 1] = temp;
|
||
}
|
||
}
|
||
}
|
||
for (var i in moneyArray) {
|
||
tmp_ys_total = tmp_ys_total + '<div style="float:left;width: 80px;margin-left:2px;"><span>' + moneyArray[i].moneyname + ':</span>'
|
||
+ '<span>' + Math.round(Number(moneyArray[i].amount_ys) * 100) / 100 + '</span></div>';
|
||
tmp_yf_total = tmp_yf_total + '<div style="float:left;width: 80px;margin-left:2px;"><span>' + moneyArray[i].moneyname + ':</span>'
|
||
+ '<span>' + Math.round(Number(moneyArray[i].amount_yf) * 100) / 100 + '</span></div>';
|
||
tmp_zd_total_c = tmp_zd_total_c + '<div style="float:left;width: 80px;margin-left:2px;"><span>' + moneyArray[i].moneyname + ':</span>'
|
||
+ '<span>' + Math.round(Number(Number(moneyArray[i].amount_ys) - Number(moneyArray[i].amount_yf)) * 100) / 100
|
||
+ '</span></div>';
|
||
}
|
||
document.getElementById('ys_total').innerHTML = tmp_ys_total;
|
||
document.getElementById('yf_total').innerHTML = tmp_yf_total;
|
||
document.getElementById('lr_total').innerHTML = tmp_zd_total_c;
|
||
|
||
var ze_ys = '<div style="float:left;width: 80px;margin-left:2px;">'
|
||
+ '<span>' + Math.round(Number(amount_ze_ys) * 100) / 100 + '</span></div>';
|
||
document.getElementById('ys_amount').innerHTML = ze_ys;
|
||
|
||
var ze_yf = '<div style="float:left;width: 80px;margin-left:2px;">'
|
||
+ '<span>' + Math.round(Number(amount_ze_yf) * 100) / 100 + '</span></div>';
|
||
document.getElementById('yf_amount').innerHTML = ze_yf;
|
||
|
||
var mlamount = Number(Math.round((Number(amount_ze_ys) - Number(amount_ze_yf)) * 100) / 100);
|
||
var tmp_ze = '<div style="float:left;width: 80px;margin-left:2px;">'
|
||
+ '<span>' + mlamount + '</span></div>';
|
||
document.getElementById('lr_amount').innerHTML = tmp_ze;
|
||
}
|
||
|
||
|
||
function SetLabelUSD() {
|
||
$('#lab_ysusd').text('应收美金');
|
||
$('#lab_yfusd').text('应付美金');
|
||
$('#lab_lrusd').text('美金利润');
|
||
}
|
||
|
||
|
||
function calculateAmount(rowIndex) {
|
||
//alert('calculateAmount');
|
||
|
||
var priceEditor = $('#feegrid').datagrid('getEditor', {
|
||
index: rowIndex,
|
||
field: 'mx_price'
|
||
});
|
||
var qtyEditor = $('#feegrid').datagrid('getEditor', {
|
||
index: rowIndex,
|
||
field: 'mx_qty'
|
||
});
|
||
var amountEditor = $('#feegrid').datagrid('getEditor', {
|
||
index: rowIndex,
|
||
field: 'mx_amount_root'
|
||
});
|
||
var exrateEditor = $('#feegrid').datagrid('getEditor', {
|
||
index: rowIndex,
|
||
field: 'mx_exrate'
|
||
});
|
||
var amountrmbEditor = $('#feegrid').datagrid('getEditor', {
|
||
index: rowIndex,
|
||
field: 'mx_amount'
|
||
});
|
||
var strprice = priceEditor.target.val();
|
||
var strqty = qtyEditor.target.val();
|
||
var x = /^(\+|-)?\d+($|\.\d+$)/;
|
||
if (!x.test(strprice)) {
|
||
//priceEditor.target.val('0');
|
||
strprice = 0;
|
||
priceEditor.target.val(0);
|
||
}
|
||
if (!x.test(strqty)) {
|
||
//qtyEditor.target.val('0');
|
||
strqty = 0;
|
||
qtyEditor.target.val(0);
|
||
}
|
||
var cost = strprice * strqty;
|
||
//priceEditor.target.val() * qtyEditor.target.val();
|
||
amountEditor.target.val(cost);
|
||
var amountrmb = cost * exrateEditor.target.val();
|
||
amountrmbEditor.target.val(amountrmb);
|
||
calcw();
|
||
|
||
}
|
||
|
||
function onClickRow_fee(index, row) {
|
||
if (row.mx_sh == '1' || row.alreadyamount > 0) {
|
||
//alert('12321');
|
||
//$('#feegrid').datagrid('getEditor', {index: index, field:'mx_sh'}).target.attr("readonly",true);
|
||
return;
|
||
}
|
||
// if (editIndex_fee != index){
|
||
if (endEditing_fee()) {
|
||
$('#feegrid').datagrid('beginEdit', index);
|
||
editIndex_fee = index;
|
||
setEditing(index);
|
||
} else {
|
||
$('#feegrid').datagrid('selectRow', editIndex_fee);
|
||
}
|
||
// }
|
||
|
||
}
|
||
function onClickRow_sub(index, row) {
|
||
/*if (endEditing_sub()) {
|
||
$('#subgrid').datagrid('beginEdit', index);
|
||
editIndex_sub = index;
|
||
//setEditing_sub(index);
|
||
} else {
|
||
$('#subgrid').datagrid('selectRow', editIndex_sub);
|
||
}*/
|
||
|
||
loaddata_detail_feesuo('feegridsuo', 'v_xg_buyin_cw', strid, row.subid, row.mx_keyid, '');
|
||
}
|
||
|
||
function showfee(i) {
|
||
/*if (endEditing_sub()) {
|
||
$('#subgrid').datagrid('beginEdit', index);
|
||
editIndex_sub = index;
|
||
//setEditing_sub(index);
|
||
} else {
|
||
$('#subgrid').datagrid('selectRow', editIndex_sub);
|
||
}*/
|
||
var e = window.event || e;
|
||
if (e.stopPropagation) {
|
||
e.stopPropagation(); //阻止事件 冒泡传播
|
||
}
|
||
var index = $(i).parents("tr:first").attr("datagrid-row-index");
|
||
index = parseInt(index);
|
||
console.log(index);
|
||
var row = $('#subgrid').datagrid('getRows')[index];
|
||
//console.log(row);
|
||
|
||
loaddata_detail_feesuo('feegridsuo', 'v_xg_buyin_cw', strid, row.subid, row.mx_keyid, '');
|
||
}
|
||
|
||
|
||
function loaddata_detail_feesuo(gridname, viewname, strid, subid, conno, options) {
|
||
var strid = strid;
|
||
if (!subid) {
|
||
return
|
||
}
|
||
//var strtemp=getFeeLevelSQL(userid);
|
||
var ssubid = subid.replace('{', '');
|
||
ssubid = subid.replace('}', '');
|
||
var searchcondition = "father = '" + strid + "'" + " and (mx_linkfd_id='" + ssubid + "' or mx_linkfd_id='" + subid + "')";
|
||
if (loginfee == '1') {
|
||
searchcondition = searchcondition + " and mx_feetype_id in (select b_feetype_id from b_user_feetype where b_user_id='" + userid + "')";
|
||
}
|
||
//var searchcondition = "(father='" + strid + "') and "+strtemp+ "' and mx_linkcon_id= '"+ Fconsubid +"'";
|
||
//alert(searchcondition);
|
||
$.ajax({
|
||
type: 'post',
|
||
url: 'jsp/loaddata.jsp',
|
||
cache: false,
|
||
async: false,
|
||
data: {
|
||
soption: options,
|
||
searchcondition: searchcondition,
|
||
viewname: viewname,
|
||
orderfield: 'mx_xh'
|
||
},
|
||
dataType: 'json', // 服务器返回时接收的数据类型
|
||
success: function (result) {
|
||
$('#' + gridname).datagrid('loadData', result);
|
||
},
|
||
error: function (result) {
|
||
|
||
}
|
||
|
||
});
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
function removeitfee(o) {
|
||
var e = window.event || e;
|
||
if (e.stopPropagation) {
|
||
e.stopPropagation(); //阻止事件 冒泡传播
|
||
}
|
||
// var selindex = $(o).attr('attr1');
|
||
// let editIndex=Number(curindex) + 1;
|
||
// var gridid = 'feegrid';
|
||
|
||
var selid = $(o).attr('attr1');
|
||
var selindex = $("#feegrid").datagrid('getRowIndex', selid);
|
||
var curindex = $("#feegrid").datagrid('getRows').length;
|
||
if ($("#feegrid").datagrid('getRows')[selindex].alreadyamount == 0) {
|
||
$.messager.confirm("操作提示", '您确定要删除选中的数据吗?', function (r) {
|
||
if (!r) {
|
||
return false;
|
||
} else {
|
||
$("#feegrid").datagrid('deleteRow', selindex);
|
||
$("#feegrid").datagrid('options').editIndex = undefined;
|
||
let rows = $("#feegrid").datagrid('getRows');
|
||
for (var i = selindex; i < rows.length; i++) {
|
||
rows[i].mx_xh = Number(i) + 1;
|
||
}
|
||
$("#feegrid").datagrid('loadData', rows);
|
||
// computeFooter_fee();
|
||
if (curindex <= 1) {
|
||
$('#feegrid').datagrid('appendRow', {
|
||
mx_level: 1,
|
||
//mx_type_id : '应收',
|
||
mx_hstype_id: '买箱入库',
|
||
mx_xh: 1,
|
||
mx_intputman_id: userid,
|
||
mx_inputdate: getnowdate(),
|
||
alreadyamount: 0,
|
||
notamount: 0,
|
||
});
|
||
editIndex_fee = curindex - 1;
|
||
//alert(editIndex_fee);
|
||
$('#feegrid').datagrid('beginEdit', editIndex_fee);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
function addfee(o) {
|
||
var e = window.event || e;
|
||
if (e.stopPropagation) {
|
||
e.stopPropagation(); //阻止事件 冒泡传播
|
||
}
|
||
|
||
var gridid = 'feegrid';
|
||
if (endEditing_fee()) {
|
||
var curindex = $(o).attr('attr1');
|
||
let editIndex = Number(curindex) + 1;
|
||
let irow = $('#feegrid').datagrid('getRows').length;
|
||
if (editIndex >= irow) {
|
||
$('#feegrid').datagrid('appendRow', {
|
||
mx_xh: Number(curindex) + 1,
|
||
mx_level: 1,
|
||
//mx_type_id : '应收',
|
||
mx_hstype_id: '买箱入库',
|
||
mx_intputman_id: userid,
|
||
mx_inputdate: getnowdate(),
|
||
alreadyamount: 0,
|
||
notamount: 0,
|
||
});
|
||
} else {
|
||
$('#feegrid').datagrid('insertRow', {
|
||
index: editIndex,
|
||
row: {
|
||
mx_xh: Number(curindex) + 1,
|
||
mx_level: 1,
|
||
//mx_type_id : '应收',
|
||
mx_hstype_id: '买箱入库',
|
||
mx_intputman_id: userid,
|
||
mx_inputdate: getnowdate(),
|
||
alreadyamount: 0,
|
||
notamount: 0,
|
||
}
|
||
});
|
||
}
|
||
let rows = $('#feegrid').datagrid('getRows');
|
||
for (var i = editIndex; i < rows.length; i++) {
|
||
rows[i].mx_xh = Number(i) + 1;
|
||
}
|
||
$('#feegrid').datagrid('loadData', rows);
|
||
$('#feegrid').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
|
||
$('#feegrid').datagrid('options').editIndex = editIndex;
|
||
editIndex_fee = editIndex;
|
||
}
|
||
}
|
||
function append_fee() {
|
||
if (endEditing_fee()) {
|
||
editIndex_fee = $('#feegrid').datagrid('getRows').length;
|
||
$('#feegrid').datagrid('appendRow', {
|
||
mx_xh: editIndex_fee + 1,
|
||
mx_level: 1,
|
||
//mx_type_id : '应收',
|
||
mx_hstype_id: '买箱入库',
|
||
mx_intputman_id: userid,
|
||
mx_inputdate: getnowdate(),
|
||
alreadyamount: 0,
|
||
notamount: 0,
|
||
});
|
||
|
||
|
||
|
||
$('#feegrid').datagrid('beginEdit', editIndex_fee);
|
||
}
|
||
}
|
||
|
||
function append_con() {
|
||
var contype = $('#b_contype').val();
|
||
var Fdate = '';
|
||
if (orgid != 'shltpn') {
|
||
Fdate = $('#b_date').val();
|
||
}
|
||
|
||
if (endEditing_sub()) {
|
||
var newRow = {
|
||
mx_type: '买箱入库',
|
||
mx_contype: contype,
|
||
mx_xh: getguid(),
|
||
mx_xk: $('#b_xk').val(),
|
||
mx_xz: '是',
|
||
mx_date: $('#b_date').val(),
|
||
mx_zxdate: Fdate,
|
||
mx_city_id: $('#b_city_id').val(),
|
||
v_mx_city_name: $('#v_cityname').val(),
|
||
mx_atwhere: $('#b_atwhere').val(),
|
||
v_mx_atwhere_name: $('#v_b_atwhere_name').val(),
|
||
mx_txid: $('#b_txid').val()
|
||
};
|
||
allRows.push(newRow);
|
||
$('#subgrid').datagrid('loadData', allRows);
|
||
|
||
let newIndex = allRows.length - 1;
|
||
|
||
$('#subgrid').datagrid('selectRow', newIndex);
|
||
$('#subgrid').datagrid('beginEdit', newIndex);
|
||
editIndex_sub = newIndex;
|
||
$('#subgrid').datagrid('scrollTo', newIndex);
|
||
}
|
||
}
|
||
|
||
|
||
function setxh_fee1() {
|
||
var i = 0;
|
||
var rows = $("#feegrid").datagrid("getRows");
|
||
var irow = $("#feegrid").datagrid("getRows").length;
|
||
//alert(irow);
|
||
for (i = 0; i < irow; i++) {
|
||
$('#feegrid').datagrid('updateRow', {
|
||
index: i,
|
||
row: {
|
||
mx_xh: i + 1
|
||
}
|
||
});
|
||
$('#feegrid').datagrid('refreshRow', i);
|
||
|
||
};
|
||
}
|
||
|
||
function setxh_fee() {
|
||
var i = 0;
|
||
var rows = $("#feegrid").datagrid("getRows");
|
||
var irow = $("#feegrid").datagrid("getRows").length;
|
||
for (i = 0; i < irow; i++) {
|
||
$('#feegrid').datagrid('beginEdit', i);
|
||
editIndex_fee = i;
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: i,
|
||
field: 'mx_xh'
|
||
}).target.val(i + 1);
|
||
endEditing_fee();
|
||
}
|
||
}
|
||
|
||
function insert_fee() {
|
||
var index;
|
||
if (editIndex_fee == undefined) {
|
||
var row = $('#feegrid').datagrid('getSelected');
|
||
if (!row) {
|
||
return
|
||
};
|
||
index = $('#feegrid').datagrid('getRowIndex', row);
|
||
} else {
|
||
index = editIndex_fee;
|
||
}
|
||
|
||
if (endEditing_fee()) {
|
||
$('#feegrid').datagrid('insertRow', {
|
||
index: index,
|
||
row: {
|
||
mx_xh: index + 1,
|
||
mx_level: 1,
|
||
//mx_type_id : '应收',
|
||
mx_hstype_id: '买箱入库',
|
||
mx_intputman_id: userid,
|
||
mx_inputdate: getnowdate()
|
||
}
|
||
});
|
||
//setxh_fee();
|
||
$('#feegrid').datagrid('selectRow', index).datagrid('beginEdit', index);
|
||
editIndex_fee = index;
|
||
}
|
||
}
|
||
|
||
function insert_con() {
|
||
var index;
|
||
if (editIndex_sub == undefined) {
|
||
var row = $('#feegrid').datagrid('getSelected');
|
||
if (!row) {
|
||
return
|
||
};
|
||
index = $('#subgrid').datagrid('getRowIndex', row);
|
||
} else {
|
||
index = editIndex_sub;
|
||
}
|
||
|
||
if (endEditing_sub()) {
|
||
$('#subgrid').datagrid('insertRow', {
|
||
index: index,
|
||
row: {
|
||
mx_type: '买箱入库',
|
||
mx_date: $('#b_date').val()
|
||
}
|
||
});
|
||
|
||
$('#subgrid').datagrid('selectRow', index).datagrid('beginEdit', index);
|
||
editIndex_sub = index;
|
||
}
|
||
}
|
||
|
||
function copyrecord_fee() {
|
||
var rows = $('#feegrid').datagrid('getSelected');
|
||
if (!rows) {
|
||
return
|
||
};
|
||
var index = $('#feegrid').datagrid('getRowIndex', rows);
|
||
index = index + 1;
|
||
var rowsjson = app.jsonToString(rows);
|
||
var obj = eval('(' + rowsjson + ')');
|
||
delete obj["subid"];
|
||
if (endEditing_fee()) {
|
||
$('#feegrid').datagrid('insertRow', { index: index, row: obj });
|
||
$('#feegrid').datagrid('selectRow', index).datagrid('beginEdit', index);
|
||
editIndex_fee = index;
|
||
}
|
||
$('#feegrid').datagrid('selectRow', index).datagrid('beginEdit', index);
|
||
editIndex_fee = index;
|
||
}
|
||
|
||
|
||
|
||
function mx_shClick(o) {
|
||
var index = $(o).attr('rowIndex');
|
||
if (editIndex_fee)
|
||
$('#feegrid').datagrid('endEdit', editIndex_fee);
|
||
$('#feegrid').datagrid('options').onBeginEdit = function () {
|
||
return;
|
||
};
|
||
$('#feegrid').datagrid('beginEdit', index);
|
||
editIndex_fee = index;
|
||
canedit = '1';
|
||
if (!$(o).get(0).checked) {
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_sh'
|
||
}).target.prop("checked", false);
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_shman_id'
|
||
}).target.val('');
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_shdate'
|
||
}).target.val('');
|
||
} else {
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_sh'
|
||
}).target.prop("checked", true);
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_shman_id'
|
||
}).target.val(userid);
|
||
$('#feegrid').datagrid('getEditor', {
|
||
index: index,
|
||
field: 'mx_shdate'
|
||
}).target.val(getnowdate());
|
||
}
|
||
$('#feegrid').datagrid('endEdit', editIndex_fee);
|
||
$('#feegrid').datagrid('options').onBeginEdit = onBeginEdit_fee;
|
||
|
||
}
|
||
|
||
function removeit_fee() {
|
||
var selectedrows = $('#feegrid').datagrid('getChecked');
|
||
if (selectedrows.length <= 0) {
|
||
return false;
|
||
};
|
||
$.messager.confirm("操作提示", '您确定要删除选中的数据吗?', function (r) {
|
||
if (!r) {
|
||
return false;
|
||
}
|
||
else {
|
||
var hassh = false;
|
||
for (i = selectedrows.length - 1; i >= 0; i--) {
|
||
if (selectedrows[i].mx_sh == '1') {
|
||
hassh = true;
|
||
} else {
|
||
$('#feegrid').datagrid('deleteRow', $('#feegrid').datagrid('getRowIndex', selectedrows[i]));
|
||
}
|
||
}
|
||
if (hassh)
|
||
alert('已经审核的费用不能删除');
|
||
//setxh_fee2();
|
||
editIndex_fee = undefined;
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
|
||
function selecthistory() {
|
||
//alert('111');
|
||
if ($('#b_customer_id').val() == '') {
|
||
alert('请先选定委托单位,再来选择业务费用!');
|
||
return;
|
||
}
|
||
var sparams = new Array();
|
||
var desgrid = "feegrid";
|
||
var selectid = "hishtcw_bsys";
|
||
var moduleid = "bs_ht";
|
||
var userid = "";
|
||
var parentfrm = self.name;
|
||
var options = "{mx_date:'" + getnowdate() + "',mx_user_id:'" + "'}";
|
||
// alert(options);
|
||
|
||
sparams.push($('#b_customer_id').val());
|
||
//sparams.push("ZHOUSHANPENGXIANG");
|
||
var psparams = sparams.join(",");
|
||
var url = "jselectdialog/dataSelectMuti.jsp?parentfrm=" + parentfrm
|
||
+ "&desgrid=" + desgrid + "&selectid=" + selectid + "&moduleid="
|
||
+ moduleid + "&psparams=" + psparams + "&userid=" + userid
|
||
+ "&options=" + options;
|
||
|
||
var datadialog = parent.$('<div/>').dialog({
|
||
title: '数据选取',
|
||
width: 888,
|
||
height: 500,
|
||
// left:50,
|
||
top: 50,
|
||
onClose: function (event, ui) {
|
||
updatehl();
|
||
},
|
||
content: '<iframe id="" src="'
|
||
+ url
|
||
+ '" allowTransparency="true" scrolling="auto" width="100%" height="99.3%" frameBorder="0" name=""></iframe>',
|
||
modal: true
|
||
});
|
||
}
|
||
|
||
|
||
function showxzmod() {
|
||
var row = $('#feegrid').datagrid('getSelected');
|
||
var url;
|
||
if (row != undefined) {
|
||
if (row.mx_type_id == '应付') {
|
||
url = "jcw/payxzmod.jsp?businessid=" + row.subid;
|
||
} else if (row.mx_type_id == '应收') {
|
||
url = "jcw/receivexzmod.jsp?businessid=" + row.subid;
|
||
}
|
||
if (url != undefined) {
|
||
var datadialog = parent.$('<div/>').dialog({
|
||
title: '销账明细',
|
||
width: 640,
|
||
height: 400,
|
||
content: '<iframe id="" src="'
|
||
+ url
|
||
+ '" allowTransparency="true" scrolling="auto" width="100%" height="99.2%" frameBorder="0" name=""></iframe>',
|
||
modal: true
|
||
});
|
||
}
|
||
}
|
||
}
|
||
|
||
function loaddata_detail_fee(gridname, viewname, strid, options) {
|
||
var strid = strid;
|
||
var strtemp = getFeeLevelSQL(userid);
|
||
var searchcondition = "(father='" + strid + "') and " + strtemp;
|
||
$.ajax({
|
||
type: 'post',
|
||
url: 'jsp/loaddata.jsp',
|
||
cache: false,
|
||
async: false,
|
||
data: {
|
||
soption: options,
|
||
searchcondition: searchcondition,
|
||
viewname: viewname,
|
||
orderfield: 'mx_xh'
|
||
},
|
||
dataType: 'json', // 服务器返回时接收的数据类型
|
||
success: function (result) {
|
||
$('#' + gridname).datagrid('loadData', result);
|
||
},
|
||
error: function (result) {
|
||
|
||
}
|
||
});
|
||
}
|
||
|
||
function loaddata_detail_sub(gridname, viewname, strid, options) {
|
||
var strid = strid;
|
||
|
||
var searchcondition = "(father='" + strid + "') ";
|
||
$.ajax({
|
||
type: 'post',
|
||
url: 'jsp/loaddata.jsp',
|
||
cache: false,
|
||
async: false,
|
||
data: {
|
||
soption: options,
|
||
searchcondition: searchcondition,
|
||
viewname: viewname,
|
||
orderfield: 'mx_xh'
|
||
},
|
||
dataType: 'json', // 服务器返回时接收的数据类型
|
||
success: function (result) {
|
||
subgridRows = result
|
||
subgridjson = app.jsonToString(subgridRows)
|
||
|
||
var $grid = $('#' + gridname);
|
||
$grid.datagrid('loadData', result);
|
||
|
||
$('#subgrid').datagrid('clearSelections');
|
||
$('#subgrid').datagrid('clearChecked');
|
||
},
|
||
error: function (result) {
|
||
|
||
}
|
||
});
|
||
}
|
||
|
||
function savecolumn_con() {
|
||
saveColumn('subgrid', 'v_xg_buyin_sub');
|
||
}
|
||
|
||
function savecolumn_fee() {
|
||
saveColumn('feegrid', 'v_xg_buyin_cw');
|
||
}
|
||
|
||
function createcon() {
|
||
var qty = parseInt($('#b_qty').val());
|
||
if ($('#b_qty').val() == '' || $('#b_contype').val() == '' || $('#v_b_atwhere_name').val() == '' || $('#b_xk').val() == '') {
|
||
alert('数量、箱型、箱况或堆场为空,请检查!');
|
||
return;
|
||
}
|
||
|
||
var allRows = subgridRows;
|
||
var irow = allRows.length;
|
||
|
||
var contype = $('#b_contype').val();
|
||
var Fdate = '';
|
||
if (orgid != 'shltpn') {
|
||
Fdate = $('#b_date').val();
|
||
}
|
||
|
||
for (var i = irow; i < qty; i++) {
|
||
allRows.push({
|
||
mx_contype: contype,
|
||
mx_xh: getguid(),
|
||
mx_xk: $('#b_xk').val(),
|
||
mx_xz: '是',
|
||
mx_type: '买箱入库',
|
||
mx_zxdate: Fdate,
|
||
mx_city_id: $('#b_city_id').val(),
|
||
v_mx_city_name: $('#v_cityname').val(),
|
||
mx_atwhere: $('#b_atwhere').val(),
|
||
v_mx_atwhere_name: $('#v_b_atwhere_name').val(),
|
||
mx_txid: $('#b_txid').val()
|
||
});
|
||
}
|
||
|
||
// 更新 datagrid
|
||
$('#subgrid').datagrid('loadData', allRows);
|
||
$('#subgrid').datagrid('scrollTo', allRows.length - 1);
|
||
}
|
||
|
||
function canitemidexists() {
|
||
var arritem = [];
|
||
var canuse = true;
|
||
var conno = ''
|
||
for (var i = 0; i < subgridRows.length; i++) {
|
||
var mxitemid = subgridRows[i].mx_conno;
|
||
//alert(mxitemid);
|
||
if ((mxitemid == '') || (mxitemid == undefined)) {
|
||
continue;
|
||
//canuse = false;
|
||
//break;
|
||
}
|
||
if (arritem.indexOf(mxitemid) > -1) {
|
||
if (conno != '') {
|
||
conno = conno + ";";
|
||
}
|
||
conno = conno + mxitemid;
|
||
//canuse = false;
|
||
continue;
|
||
}
|
||
arritem.push(mxitemid);
|
||
};
|
||
if (conno != '') {
|
||
conno = conno + ";";
|
||
alert("箱号:" + conno + "有重复,不能保存");
|
||
canuse = false;
|
||
}
|
||
|
||
return canuse;
|
||
}
|
||
|
||
/*function canitemidexists(){
|
||
var itemrows = $('#subgrid').datagrid('getRows');
|
||
var irow = itemrows.length;
|
||
var arritem=[];
|
||
var canuse=true;
|
||
var conno=''
|
||
for (var i = 0; i < irow; i++) {
|
||
var mxitemid=itemrows[i].mx_conno;
|
||
//alert(mxitemid);
|
||
if((mxitemid=='')||(mxitemid==undefined)){
|
||
continue;
|
||
//canuse = false;
|
||
//break;
|
||
}
|
||
if(arritem.indexOf(mxitemid)>-1){
|
||
canuse = false;
|
||
break;
|
||
}
|
||
arritem.push(mxitemid);
|
||
};
|
||
return canuse;
|
||
}*/
|
||
|
||
|
||
function createconno() {
|
||
if (checkchange()) {
|
||
alert('请先保存,再生成系统箱号!');
|
||
return;
|
||
}
|
||
var sid = $('#b_id').val();
|
||
var rows = subgridRows;
|
||
var irow = subgridRows.length;
|
||
var value = "";
|
||
for (i = 0; i < irow; i++) {
|
||
var keyid = rows[i].mx_keyid;
|
||
// alert(keyid);
|
||
if ((keyid == '') || (keyid == null) || (keyid == undefined)) {
|
||
alert("请先确认入库!");
|
||
return;
|
||
}
|
||
//alert(keyid);
|
||
var conn = rows[i].mx_conno;
|
||
if ((conn != '') && (conn != null) && (conn != undefined)) {
|
||
//alert("111");
|
||
continue;
|
||
}
|
||
|
||
var tmpjson = loaddatas('v_gx_keyrecords', "='" + keyid + "'", 'mx_shdatetime desc', '');
|
||
if (tmpjson.length > 0) {
|
||
if (tmpjson[0].father != strid) {
|
||
alert("112");
|
||
// alert('该箱子已使用,不能撤删!');
|
||
continue;
|
||
}
|
||
}
|
||
|
||
if (value != '') {
|
||
value = value + ','
|
||
}
|
||
value = value + "{father:'" + sid +
|
||
"',mx_conno:'" + rows[i].mx_keyid +
|
||
"',subid:'" + rows[i].subid +
|
||
"'}"
|
||
}
|
||
|
||
if (value == '') {
|
||
// alert('费用导入失败,不能重复导入费用!');
|
||
return;
|
||
}
|
||
|
||
value = "[" + value + "]";
|
||
//alert(value);
|
||
$.ajax({
|
||
type: 'post',
|
||
url: 'jsp/savesubtable.jsp',
|
||
cache: false,
|
||
data: {
|
||
subtable: 'xg_buyin_sub',
|
||
subinsertvalue: '[]',
|
||
subdelvalue: '[]',
|
||
subupdatevalue: value,
|
||
father: sid
|
||
},
|
||
dataType: 'text',
|
||
success: function (result) {
|
||
alert('箱号生成成功!');
|
||
loaddata_detail_sub('subgrid', 'v_xg_buyin_sub', strid, '');
|
||
},
|
||
error: function (result) {
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
|
||
|
||
function sh() {
|
||
$('#btn_check').attr('disabled', 'disabled');
|
||
if (checkchange()) {
|
||
alert('请先保存数据!');
|
||
$('#btn_check').removeAttr("disabled");
|
||
return;
|
||
}
|
||
var Fid = $('#b_id').val();
|
||
var Fdwid = $('#b_customer_id').val();
|
||
if (Fdwid == '') {
|
||
alert('箱公司不能为空!');
|
||
$('#btn_check').removeAttr("disabled");
|
||
return;
|
||
}
|
||
if (!canitemidexists()) {
|
||
//alert('箱号有重复,不能更新箱池!');
|
||
return;
|
||
}
|
||
|
||
var rows = $('#subgrid').datagrid('getChecked');
|
||
if (rows.length <= 0) {
|
||
var rows = subgridRows;
|
||
//return false;
|
||
};
|
||
var tmpjson;
|
||
if (!rows) {
|
||
alert('未输入买入的箱子');
|
||
$('#btn_check').removeAttr("disabled");
|
||
return;
|
||
}
|
||
|
||
/* var connoArray=[];
|
||
var Fsql=" mx_type not in('卖箱出库','还箱退租','代管出库')"
|
||
if (Fid!=''){
|
||
Fsql=Fsql+" and father<>'"+Fid+"'";
|
||
}
|
||
var tmpjson=loaddatas('xg_conmaxtype', Fsql, '', '');
|
||
for(var k in tmpjson){
|
||
if (!(strinArray(connoArray,tmpjson[k].mx_conno))){
|
||
connoArray.push(tmpjson[k].mx_conno);
|
||
}
|
||
} */
|
||
|
||
// ========= 第一轮循环:收集要批量查询的 key =========
|
||
|
||
var subidList = [];
|
||
var connoList = [];
|
||
|
||
for (var i = 0; i < rows.length; i++) {
|
||
var r = rows[i];
|
||
|
||
if (r.mx_contype == '' || r.mx_contype == null) {
|
||
alert('箱型不能为空');
|
||
$('#btn_check').removeAttr("disabled");
|
||
return;
|
||
}
|
||
if (r.mx_atwhere == '' || r.mx_atwhere == null) {
|
||
alert('存放堆场不能为空');
|
||
$('#btn_check').removeAttr("disabled");
|
||
return;
|
||
}
|
||
if (r.mx_txid == '' || r.mx_txid == null) {
|
||
alert('提箱单号不能为空');
|
||
$('#btn_check').removeAttr("disabled");
|
||
return;
|
||
}
|
||
|
||
// 已确认记录直接跳过,不参与重复确认查询
|
||
if (r.mx_keyid != '' && r.mx_keyid != null && r.mx_keyid != undefined) {
|
||
continue;
|
||
}
|
||
|
||
// subid 批量收集(包含 { } 两种形式)
|
||
if (r.subid) {
|
||
var s1 = r.subid;
|
||
var s2 = r.subid.replace('{', '').replace('}', '');
|
||
subidList.push(s1, s2);
|
||
}
|
||
|
||
// conno 批量收集
|
||
if (r.mx_conno) {
|
||
connoList.push(r.mx_conno);
|
||
}
|
||
}
|
||
|
||
// 去重
|
||
subidList = Array.from(new Set(subidList));
|
||
connoList = Array.from(new Set(connoList));
|
||
// ========= 第二阶段:一次性批量查询 DB =========
|
||
|
||
// ① 已确认的箱(避免重复确认)
|
||
var confirmedMap = new Set();
|
||
if (subidList.length > 0) {
|
||
var sql1 = " father = '" + Fid + "' AND mx_link_id IN ('" + subidList.join("','") + "')";
|
||
var tmp1 = loaddatas('xg_conmaxtype', sql1, '', '');
|
||
for (var t = 0; t < tmp1.length; t++) {
|
||
confirmedMap.add(tmp1[t].mx_link_id);
|
||
}
|
||
}
|
||
|
||
// ② 箱池中已存在的箱号(避免重复输入)
|
||
var connoMap = new Set();
|
||
if (connoList.length > 0) {
|
||
var sql2 =
|
||
" father <> '" + Fid + "' " +
|
||
" AND mx_conno IN ('" + connoList.join("','") + "')" +
|
||
" AND mx_type NOT IN ('卖箱出库','还箱退租','代管出库')";
|
||
var tmp2 = loaddatas('xg_conmaxtype', sql2, '', '');
|
||
for (var k = 0; k < tmp2.length; k++) {
|
||
connoMap.add(tmp2[k].mx_conno);
|
||
}
|
||
}
|
||
|
||
|
||
// ========= 第三轮循环:逐条判断 =========
|
||
for (var i = 0; i < rows.length; i++) {
|
||
var r = rows[i];
|
||
|
||
// 跳过已确认记录
|
||
if (!(r.mx_keyid != '' && r.mx_keyid != null && r.mx_keyid != undefined)) {
|
||
|
||
// 判断 subid 是否重复确认
|
||
if (r.subid) {
|
||
var s1 = r.subid;
|
||
var s2 = r.subid.replace('{', '').replace('}', '');
|
||
if (confirmedMap.has(s1) || confirmedMap.has(s2)) {
|
||
alert('已确认的箱子不可重复确认!');
|
||
$('#btn_sh').removeAttr("disabled");
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 判断箱号是否在箱池中存在
|
||
if (r.mx_conno) {
|
||
if (connoMap.has(r.mx_conno)) {
|
||
alert('箱号:' + r.mx_conno + '在箱池中已经存在,不可重复输入!');
|
||
$('#btn_check').removeAttr("disabled");
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
var rows1 = [];
|
||
var minid = getAutoID('xg_buyin_autokeyid', 'g3soft');
|
||
if ((minid == '') || (minid == null) || (minid == undefined)) {
|
||
alert('系统箱号出错,确认失败,请重新确认!');
|
||
$('#btn_check').removeAttr("disabled");
|
||
return;
|
||
}
|
||
var Fstrid = $('#b_id').val();
|
||
var Fywid = '';
|
||
Fywid = Fstrid.substr(Fstrid.length - 3, Fstrid.length);
|
||
var n = 0;
|
||
console.log(Fywid);
|
||
// return;
|
||
// alert(minid);
|
||
|
||
var Fdate = getnowtime();
|
||
|
||
var subdata = [];
|
||
var subdata1 = [];
|
||
var subdata2 = [];
|
||
var subdata3 = [];
|
||
var maindata = {};
|
||
var tmpdata = {};
|
||
var tmpdata1 = {};
|
||
var tmpdata2 = {};
|
||
var tmpdata3 = {};
|
||
/////////修改确认xg_buyin//////
|
||
maindata = {};
|
||
maindata.b_id = $('#b_id').val();
|
||
maindata.b_sh = '1';
|
||
maindata.b_shman_id = userid;
|
||
maindata.b_shdatetime = Fdate;
|
||
//////////////////
|
||
|
||
for (var i = 0; i < rows.length; i++) {
|
||
var Fkeyid = rows[i].mx_keyid;
|
||
if ((Fkeyid != '') && (Fkeyid != null) && (Fkeyid != undefined)) {
|
||
continue;
|
||
}
|
||
var conkeyid = (Number(minid) + n).toString() + '1' + Fywid;
|
||
n = n + 1;
|
||
|
||
var contype = rows[i].mx_contype;
|
||
var txid = rows[i].mx_txid;
|
||
var xk = rows[i].mx_xk;
|
||
var atwhere = rows[i].mx_atwhere;
|
||
var txdate = rows[i].mx_zxdate;
|
||
var bz1 = rows[i].mx_bz1;
|
||
|
||
if ((contype == undefined) || (contype == null)) { contype = ''; }
|
||
if ((txid == undefined) || (txid == null)) { txid = ''; }
|
||
if ((xk == undefined) || (xk == null)) { xk = ''; }
|
||
if ((atwhere == undefined) || (atwhere == null)) { atwhere = ''; }
|
||
if ((txdate == undefined) || (txdate == null)) { txdate = ''; }
|
||
if ((bz1 == undefined) || (bz1 == null)) { bz1 = ''; }
|
||
|
||
/////////修改确认/xg_buyin_sub//////
|
||
tmpdata = {};
|
||
tmpdata.mx_sh = '1';
|
||
tmpdata.mx_shman_id = userid;
|
||
tmpdata.mx_shdatetime = Fdate;
|
||
tmpdata.mx_keyid = conkeyid;
|
||
tmpdata.mx_date = $('#b_date').val();
|
||
tmpdata.mx_dw_id = Fdwid;
|
||
tmpdata.subid = rows[i].subid;
|
||
subdata.push(tmpdata);
|
||
|
||
//////////插入xg_keyrecords//////
|
||
tmpdata1 = {};
|
||
tmpdata1.mx_conno = rows[i].mx_conno;
|
||
tmpdata1.mx_contype = contype;
|
||
tmpdata1.mx_txid = txid;
|
||
tmpdata1.mx_xk = xk;
|
||
tmpdata1.mx_bz1 = bz1;
|
||
tmpdata1.mx_atwhere = atwhere;
|
||
tmpdata1.mx_txdate = txdate;
|
||
tmpdata1.mx_xgyw = 'xg';
|
||
tmpdata1.father = $('#b_id').val();
|
||
tmpdata1.mx_sh = '1';
|
||
tmpdata1.mx_shman_id = userid;
|
||
tmpdata1.mx_shdatetime = Fdate;
|
||
tmpdata1.mx_keyid = conkeyid;
|
||
tmpdata1.mx_date = $('#b_date').val();
|
||
tmpdata1.mx_dw_id = Fdwid;
|
||
tmpdata1.mx_link_id = rows[i].subid;
|
||
tmpdata1.mx_type = '买箱入库';
|
||
subdata1.push(tmpdata1);
|
||
|
||
//////////插入xg_conmaxtype///////
|
||
tmpdata2 = {};
|
||
tmpdata2.mx_conno = rows[i].mx_conno;
|
||
tmpdata2.mx_contype = contype;
|
||
tmpdata2.mx_txid = txid;
|
||
tmpdata2.mx_xk = xk;
|
||
tmpdata2.mx_bz1 = bz1;
|
||
tmpdata2.mx_atwhere = atwhere;
|
||
tmpdata2.mx_txdate = txdate;
|
||
tmpdata2.mx_xgyw = 'xg';
|
||
tmpdata2.father = $('#b_id').val();
|
||
tmpdata2.mx_sh = '1';
|
||
tmpdata2.mx_shman_id = userid;
|
||
tmpdata2.mx_shdatetime = Fdate;
|
||
tmpdata2.mx_keyid = conkeyid;
|
||
tmpdata2.mx_date = $('#b_date').val();
|
||
tmpdata2.mx_dw_id = Fdwid;
|
||
tmpdata2.mx_link_id = rows[i].subid;
|
||
tmpdata2.mx_type = '买箱入库';
|
||
subdata2.push(tmpdata2);
|
||
}
|
||
|
||
// ===== 优化 xg_cw 查询 =====
|
||
// 收集所有 subid(包含 {} 形式)
|
||
var allSubidList = [];
|
||
rows.forEach(r => {
|
||
if (r.subid) {
|
||
allSubidList.push(r.subid);
|
||
allSubidList.push(r.subid.replace('{', '').replace('}', ''));
|
||
}
|
||
});
|
||
allSubidList = Array.from(new Set(allSubidList));
|
||
|
||
// 一次性批量查询 xg_cw
|
||
var xgcwMap = {}; // key: mx_linkfd_id -> 对应 xg_cw 记录数组
|
||
if (allSubidList.length > 0) {
|
||
var searchsqlcw = " father ='" + Fid + "' AND (" +
|
||
allSubidList.map(sid => "mx_linkfd_id='" + sid + "'").join(" OR ") +
|
||
")";
|
||
var xgcwrows = loaddatas('xg_cw', searchsqlcw, 'subid', '');
|
||
xgcwrows.forEach(r => {
|
||
if (!xgcwMap[r.mx_linkfd_id]) xgcwMap[r.mx_linkfd_id] = [];
|
||
xgcwMap[r.mx_linkfd_id].push(r);
|
||
});
|
||
}
|
||
|
||
// 循环 rows,生成 subdata3
|
||
for (var i = 0; i < rows.length; i++) {
|
||
var r = rows[i];
|
||
var conkeyid = (Number(minid) + i).toString() + '1' + Fywid; // 保持原 keyid 逻辑
|
||
var contype = r.mx_contype || '';
|
||
var txid = r.mx_txid || '';
|
||
var xk = r.mx_xk || '';
|
||
var atwhere = r.mx_atwhere || '';
|
||
var txdate = r.mx_zxdate || '';
|
||
|
||
var subid = r.subid;
|
||
var ssubid = subid.replace('{', '').replace('}', '');
|
||
|
||
var relatedCw = (xgcwMap[subid] || []).concat(xgcwMap[ssubid] || []);
|
||
relatedCw.forEach(cw => {
|
||
var tmpdata3 = {};
|
||
tmpdata3.mx_keyid = conkeyid;
|
||
tmpdata3.mx_shdatetime = Fdate;
|
||
tmpdata3.mx_conno = r.mx_conno;
|
||
tmpdata3.mx_contype = contype;
|
||
tmpdata3.mx_txid = txid;
|
||
tmpdata3.mx_xk = xk;
|
||
tmpdata3.mx_atwhere = atwhere;
|
||
tmpdata3.mx_txdate = txdate;
|
||
tmpdata3.subid = cw.subid;
|
||
subdata3.push(tmpdata3);
|
||
});
|
||
}
|
||
|
||
/////////////////////
|
||
//console.log('vcvcvcvcvcvc');
|
||
var subjson = app.jsonToString(subdata);
|
||
//console.log('subjson:'+subjson);
|
||
var subjson1 = app.jsonToString(subdata1);
|
||
//console.log("subjson1:"+subjson1);
|
||
var subjson2 = app.jsonToString(subdata2);
|
||
//console.log("subjson2:"+subjson2);
|
||
var subjson3 = app.jsonToString(subdata3);
|
||
//console.log("subjson3:"+subjson3);
|
||
//alert(subjson);
|
||
//////////////////////////////////////////
|
||
var subtable = new Array();
|
||
var keyid = new Array();
|
||
var subinsertvalue = new Array();
|
||
var subupdatevalue = new Array();
|
||
var subdelvalue = new Array();
|
||
subtable.push('xg_buyin');
|
||
subtable.push('xg_buyin_sub');
|
||
subtable.push('xg_keyrecords');
|
||
subtable.push('xg_conmaxtype');
|
||
subtable.push('xg_cw');
|
||
|
||
var formjson = app.jsonToString(maindata);
|
||
//console.log("formjson:"+formjson);
|
||
subinsertvalue.push('[]');
|
||
subinsertvalue.push('[]');
|
||
subinsertvalue.push(subjson1);
|
||
subinsertvalue.push(subjson2);
|
||
subinsertvalue.push('[]');
|
||
|
||
subupdatevalue.push('[' + formjson + ']');
|
||
subupdatevalue.push(subjson);
|
||
subupdatevalue.push('[]');
|
||
subupdatevalue.push('[]');
|
||
subupdatevalue.push(subjson3);
|
||
|
||
subdelvalue.push('[]');
|
||
subdelvalue.push('[]');
|
||
subdelvalue.push('[]');
|
||
subdelvalue.push('[]');
|
||
subdelvalue.push('[]');
|
||
|
||
keyid.push('b_id');
|
||
keyid.push('subid');
|
||
keyid.push('subid');
|
||
keyid.push('subid');
|
||
keyid.push('subid');
|
||
|
||
// console.log(subtable)
|
||
// console.log(subinsertvalue)
|
||
// console.log(subdelvalue)
|
||
// console.log(subupdatevalue)
|
||
// console.log(keyid)
|
||
|
||
var sResult = '';
|
||
sResult = saveobjt(subtable, subinsertvalue, subdelvalue, subupdatevalue, keyid);
|
||
if (sResult == 'OK') {
|
||
alert('确认成功!');
|
||
$('#btn_check').removeAttr("disabled");
|
||
setywwcqty();
|
||
loaddata('buyinform', 'v_xg_buyin', strid, 'main');
|
||
// $('#btn_sh').attr('disabled','disabled');
|
||
//$('#btn_createcon').attr('disabled','disabled');
|
||
var formobj = app.serializeObject2($('#buyinform'));
|
||
delete formobj["bcheck"];
|
||
oldformjson = app.jsonToString(formobj);
|
||
|
||
loaddata_detail_sub('subgrid', 'v_xg_buyin_sub', strid, '');
|
||
} else {
|
||
alert(sResult);
|
||
$('#btn_check').removeAttr("disabled");
|
||
}
|
||
$('#btn_check').removeAttr("disabled");
|
||
}
|
||
|
||
function saveupdatecw(table, subupdatevalue) {
|
||
//alert(subupdatevalue);
|
||
$.ajax({
|
||
type: 'post',
|
||
url: 'jsp/savesubdata.jsp',
|
||
cache: false,
|
||
data: {
|
||
subtable: table,
|
||
subinsertvalue: '[]',
|
||
subdelvalue: '[]',
|
||
subupdatevalue: subupdatevalue
|
||
},
|
||
dataType: 'text',
|
||
success: function (result) {
|
||
|
||
//alert('更新箱号成功!');
|
||
},
|
||
error: function (result) {
|
||
}
|
||
});
|
||
}
|
||
|
||
function savesubtable(rowsjson) {
|
||
var sresult = '';
|
||
$.ajax({
|
||
type: 'post',
|
||
url: 'jsp/savesubtable.jsp',
|
||
cache: false,
|
||
async: false,
|
||
data: {
|
||
subtable: 'xg_buyin_sub',
|
||
subinsertvalue: '[]',
|
||
subdelvalue: '[]',
|
||
subupdatevalue: rowsjson,
|
||
father: ''
|
||
},
|
||
dataType: 'text',
|
||
success: function (result) {
|
||
sresult = result;
|
||
},
|
||
error: function (result) {
|
||
}
|
||
|
||
});
|
||
return sresult;
|
||
}
|
||
|
||
|
||
function canupdateconno(keyid, conno) {
|
||
var sstate = getfieldvaluebyid('v_xg_constate', 'b_state', 'b_id', keyid);
|
||
if (sstate != '可用') {
|
||
alert('key值:' + keyid + '的箱子当前状态为:' + sstate + ',不能更新箱号');
|
||
return false;
|
||
}
|
||
var tmpjson = loaddatas('v_xg_constate', "mx_conno='" + conno + "' and v_constate not in('卖箱出库','还箱退租')", 'b_id', '');
|
||
//var skeyid=getfieldvaluebyid('xg_container', 'b_id', 'b_conno', conno);
|
||
if (tmpjson.length > 0)
|
||
if (tmpjson[0].b_id != keyid) {
|
||
alert('箱号:' + conno + '箱池里已经存在,不能输入重复的箱号!');
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
function updateconno() {
|
||
endEditing_sub();
|
||
var rows1 = [];
|
||
var subvalue = "";
|
||
var rows = $('#subgrid').datagrid('getChecked');
|
||
|
||
//alert(rows.length);
|
||
// alert(app.jsonToString(rows));
|
||
if (rows.length <= 0) {
|
||
alert('请选择要更新箱号的箱子');
|
||
return;
|
||
}
|
||
if (!canitemidexists()) {
|
||
//alert('箱号有重复,不能更新箱池!');
|
||
return;
|
||
}
|
||
//var rows=$('#subgrid').datagrid('getRows');
|
||
for (var i = 0; i < rows.length; i++) {
|
||
if (!canupdateconno(rows[i].mx_keyid, rows[i].mx_conno)) {
|
||
return;
|
||
}
|
||
if (subvalue != '') {
|
||
subvalue += ',';
|
||
}
|
||
subvalue = subvalue + "{mx_conno:'" + rows[i].mx_conno +
|
||
//"',:'" + rows[i].+
|
||
"',subid:'" + rows[i].subid +
|
||
"'}"
|
||
}
|
||
|
||
var subdelvalue = "[" + subvalue + "]";
|
||
$.ajax({
|
||
type: 'post',
|
||
url: 'jsp/savesubdata.jsp',
|
||
cache: false,
|
||
data: {
|
||
subtable: 'xg_buyin_sub',
|
||
subinsertvalue: '[]',
|
||
subdelvalue: '[]',
|
||
subupdatevalue: subdelvalue
|
||
},
|
||
dataType: 'text',
|
||
success: function (result) {
|
||
loaddata_detail_sub('subgrid', 'v_xg_buyin_sub', strid, '');
|
||
alert('更新箱号成功!');
|
||
},
|
||
error: function (result) {
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
function saveupdatesub(subupdatevalue) {
|
||
$.ajax({
|
||
type: 'post',
|
||
url: 'jsp/savesubdata.jsp',
|
||
cache: false,
|
||
data: {
|
||
subtable: 'xg_buyin_sub',
|
||
subinsertvalue: '[]',
|
||
subdelvalue: '[]',
|
||
subupdatevalue: subupdatevalue
|
||
},
|
||
dataType: 'text',
|
||
success: function (result) {
|
||
loaddata_detail_sub('subgrid', 'v_xg_buyin_sub', strid, '');
|
||
//alert('更新箱号成功!');
|
||
},
|
||
error: function (result) {
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
function delconno() {
|
||
var rows = $('#subgrid').datagrid('getChecked');
|
||
if (rows.length <= 0) {
|
||
alert('请选择需要撤删的箱子');
|
||
return;
|
||
};
|
||
//var rows=$('#subgrid').datagrid('getRows');
|
||
var irow = rows.length;
|
||
var subvalue = "";
|
||
var rows1 = [];
|
||
$.messager.confirm("操作提示", '您确定要撤删选中的箱子吗?', function (r) {
|
||
if (!r) {
|
||
return false;
|
||
}
|
||
else {
|
||
//alert(selectedrows.length);
|
||
for (i = 0; i < irow; i++) {
|
||
var keyid = rows[i].mx_keyid;
|
||
var searchsql = " father='" + strid + "' and ='" + keyid + "' and mx_hstype_id='买箱入库'";
|
||
//alert(searchsql);
|
||
var modrows = loaddatas('xg_cw', searchsql, '', '');
|
||
if (modrows.length > 0) {
|
||
alert('请先删除该箱子下的费用!');
|
||
return
|
||
}
|
||
var searchsql = " ='" + keyid + "' ";
|
||
//alert(searchsql);
|
||
var modrows = loaddatas('xg_buyout_sub', searchsql, '', '');
|
||
if (modrows.length > 0) {
|
||
alert('该箱子已使用,不能撤删!');
|
||
return
|
||
}
|
||
var searchsql = " ='" + keyid + "' ";
|
||
//alert(searchsql);
|
||
var modrows = loaddatas('bs_business_container', searchsql, '', '');
|
||
if (modrows.length > 0) {
|
||
alert('该箱子已使用,不能撤删!');
|
||
return
|
||
}
|
||
}
|
||
for (i = 0; i < irow; i++) {
|
||
if (subvalue != '') {
|
||
subvalue += ',';
|
||
}
|
||
subvalue = subvalue + "{:'" + rows[i].mx_keyid +
|
||
"',subid:'" + rows[i].subid +
|
||
"'}"
|
||
}
|
||
var subdelvalue = "[" + subvalue + "]";
|
||
$.ajax({
|
||
type: 'post',
|
||
url: 'jsp/savesubdata.jsp',
|
||
cache: false,
|
||
data: {
|
||
subtable: 'xg_buyin_sub',
|
||
subinsertvalue: '[]',
|
||
subdelvalue: subdelvalue,
|
||
subupdatevalue: '[]'
|
||
},
|
||
dataType: 'text',
|
||
success: function (result) {
|
||
loaddata_detail_sub('subgrid', 'v_xg_buyin_sub', strid, '');
|
||
alert('撤删成功');
|
||
var rows = $('#subgrid').datagrid('getRows');
|
||
if (rows.length <= 0) {
|
||
updatefieldvaluebyid('xg_buyin', 'b_state', '草拟', 'b_id', $('#b_id').val());
|
||
$('#b_state').val('草拟');
|
||
var formobj = app.serializeObject2($('#buyinform'));
|
||
delete formobj["bcheck"];
|
||
oldformjson = app.jsonToString(formobj);
|
||
$('#btn_delcon').attr('disabled', 'disabled');
|
||
$('#btn_updatecon').attr('disabled', 'disabled');
|
||
$(":button[tag*='" + 3 + "']").removeAttr("disabled");
|
||
$('#btn_save').removeAttr("disabled");
|
||
}
|
||
},
|
||
error: function (result) {
|
||
}
|
||
});
|
||
}
|
||
});
|
||
}
|
||
|
||
function showAllcw() {
|
||
if (!document.getElementById("b_id").readOnly) {
|
||
savealert('请先保存数据!');
|
||
return;
|
||
}
|
||
if (checkchange()) {
|
||
savealert('请先保存数据!');
|
||
return;
|
||
}
|
||
var iread = '';
|
||
var ifreadonly = document.getElementById("btn_save").disabled;
|
||
if (ifreadonly) {
|
||
iread = '1';
|
||
}
|
||
var keyid = '';
|
||
var conno = '';
|
||
var Fxh = '';
|
||
var subid = '';
|
||
var strid = $('#b_id').val();
|
||
parent.$('<div/>').dialog({
|
||
title: '整单费用',
|
||
width: 850,
|
||
height: 570,
|
||
id: 'viewbuydialog',
|
||
top: 80,
|
||
content: '<iframe id="cwdialog" name="cwdialog" src="'
|
||
+ 'jxg/editxgpl_cw.jsp?id=' + strid + '&subid=' + subid + '&conno=' + conno + '&keyid=' + keyid + '&iread=' + iread + '&conxh=' + Fxh + "&hstype=买箱入库" + '&viewname=v_xg_buyin_cw' + '&modulename=xg_buyin'
|
||
+ '" allowTransparency="true" scrolling="auto" width="100%" height="98.3%" frameBorder="0"></iframe>',
|
||
modal: true,
|
||
onClose: function () {
|
||
$(this).remove();
|
||
},
|
||
onBeforeClose: function (event, ui) {
|
||
var w = top.frames["cwdialog"];
|
||
if (w.checkchange) {
|
||
if (w.checkchange()) {
|
||
w.$.sobox.pop({
|
||
cls: 'subsidy-box',
|
||
title: '远通提示',
|
||
width: 320,
|
||
maskClick: false,
|
||
content: '<div style="border:none;" class="messager-body panel-body panel-body-noborder window-body" title="" style="width: 266px;">' +
|
||
'<div class="messager-icon messager-question"></div>' +
|
||
'<div style="border:none;" class="messager-body panel-body panel-body-noborder window-body">数据有更改,是否要保存?</div>' +
|
||
'<div style="clear:both;"></div>' +
|
||
'</div>',
|
||
btn: [
|
||
{
|
||
text: '是', callback: function () {
|
||
var s = w.saveData();
|
||
if (s == '保存成功!') {
|
||
//alert('close');
|
||
mydialog = parent.$('#viewbuydialog');
|
||
mydialog.window('destroy');
|
||
return true;
|
||
}
|
||
}
|
||
},
|
||
{
|
||
text: '否', cls: 'a-sopop-cancel', callback: function () {
|
||
mydialog = parent.$('#viewbuydialog');
|
||
mydialog.window('destroy');
|
||
return true;
|
||
|
||
}
|
||
},
|
||
{
|
||
text: '取消', cls: 'a-sopop-cancel', callback: function () {
|
||
}
|
||
|
||
}]
|
||
})
|
||
} else {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
});
|
||
}
|
||
function showcw() {
|
||
var iread = '';
|
||
var ifreadonly = document.getElementById("btn_save").disabled;
|
||
if (ifreadonly) {
|
||
iread = '1';
|
||
}
|
||
//alert('000');
|
||
if (strid == "") {
|
||
alert('未保存数据');
|
||
return;
|
||
}
|
||
var row = $('#subgrid').datagrid('getSelected');
|
||
//alert('111');
|
||
if (!row) return;
|
||
var conno = row.mx_conno;
|
||
var keyid = row.mx_keyid;
|
||
var subid = row.subid;
|
||
//subid=subid.replace('{','');
|
||
//subid=subid.replace('}','');
|
||
var Fxh = row.mx_xh;
|
||
if ((subid == '') || (subid == null) || (subid == undefined)) {
|
||
alert("请先保存!");
|
||
return;
|
||
}
|
||
|
||
parent.$('<div/>').dialog({
|
||
title: '费用录入',
|
||
width: 880,
|
||
height: 600,
|
||
id: 'viewbuydialog',
|
||
top: 80,
|
||
resizable: true,
|
||
content: '<iframe id="cwdialog" name="cwdialog" src="'
|
||
+ 'jxg/editxg_cw.jsp?id=' + strid + '&subid=' + subid + '&conno=' + conno + '&keyid=' + keyid + '&iread=' + iread + '&conxh=' + Fxh + "&hstype=买箱入库" + '&viewname=v_xg_buyin_cw' + '&modulename=xg_buyin'
|
||
+ '" allowTransparency="true" scrolling="auto" width="100%" height="98.3%" frameBorder="0"></iframe>',
|
||
modal: true,
|
||
onClose: function () {
|
||
$(this).remove();
|
||
},
|
||
onBeforeClose: function (event, ui) {
|
||
var w = top.frames["cwdialog"];
|
||
if (w.checkchange) {
|
||
if (w.checkchange()) {
|
||
w.$.sobox.pop({
|
||
cls: 'subsidy-box',
|
||
title: '远通提示',
|
||
width: 320,
|
||
maskClick: false,
|
||
content: '<div style="border:none;" class="messager-body panel-body panel-body-noborder window-body" title="" style="width: 266px;">' +
|
||
'<div class="messager-icon messager-question"></div>' +
|
||
'<div style="border:none;" class="messager-body panel-body panel-body-noborder window-body">数据有更改,是否要保存?</div>' +
|
||
'<div style="clear:both;"></div>' +
|
||
'</div>',
|
||
btn: [
|
||
{
|
||
text: '是', callback: function () {
|
||
var s = w.saveData();
|
||
if (s == '保存成功!') {
|
||
//alert('close');
|
||
mydialog = parent.$('#viewbuydialog');
|
||
mydialog.window('destroy');
|
||
return true;
|
||
}
|
||
}
|
||
},
|
||
{
|
||
text: '否', cls: 'a-sopop-cancel', callback: function () {
|
||
mydialog = parent.$('#viewbuydialog');
|
||
mydialog.window('destroy');
|
||
return true;
|
||
|
||
}
|
||
},
|
||
{
|
||
text: '取消', cls: 'a-sopop-cancel', callback: function () {
|
||
}
|
||
|
||
}]
|
||
})
|
||
} else {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
function removeit_con() {
|
||
var checkedRows = $('#subgrid').datagrid('getChecked');
|
||
if (checkedRows.length <= 0) return false;
|
||
|
||
$.messager.confirm("操作提示", "您确定要删除选中的数据吗?", function (r) {
|
||
if (!r) return false;
|
||
|
||
// 收集 subid 和 keyid
|
||
var usedSubids = new Set();
|
||
var usedKeyids = new Set();
|
||
var subids = [], keyids = [];
|
||
|
||
checkedRows.forEach(row => {
|
||
if (row.subid) subids.push(row.subid.replace('{', '').replace('}', ''));
|
||
if (row.keyid) keyids.push(row.keyid);
|
||
});
|
||
|
||
// ====== 批量查询 ======
|
||
if (subids.length > 0) {
|
||
var searchsql = " father='" + strid + "' and mx_hstype_id='买箱入库' " +
|
||
" and mx_linkfd_id in ('" + subids.join("','") + "')";
|
||
var modrows = loaddatas('xg_cw', searchsql, '', '');
|
||
modrows.forEach(r => usedSubids.add(r.mx_linkfd_id));
|
||
}
|
||
|
||
if (keyids.length > 0) {
|
||
var searchsql1 = " mx_keyid in ('" + keyids.join("','") + "') ";
|
||
var modrows1 = loaddatas('xg_buyout_sub', searchsql1, '', '');
|
||
var modrows2 = loaddatas('bs_business_container', searchsql1, '', '');
|
||
modrows1.concat(modrows2).forEach(r => usedKeyids.add(r.mx_keyid));
|
||
}
|
||
|
||
// ====== 处理删除 ======
|
||
let canDelete = true;
|
||
for (let row of checkedRows) {
|
||
let subid = row.subid ? row.subid.replace('{', '').replace('}', '') : null;
|
||
let keyid = row.keyid;
|
||
|
||
if (subid && usedSubids.has(subid)) {
|
||
alert('请先删除该箱子下的费用!');
|
||
canDelete = false;
|
||
break; // 一旦有不允许删除的行,停止检查
|
||
}
|
||
|
||
if (keyid && usedKeyids.has(keyid)) {
|
||
alert('该箱子已使用,不能撤删!');
|
||
canDelete = false;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (!canDelete) return; // 有问题,不删除任何行
|
||
|
||
subgridRows = subgridRows.filter(row =>
|
||
!checkedRows.some(checked => checked.mx_xh === row.mx_xh)
|
||
);
|
||
|
||
$('#subgrid').datagrid('loadData', subgridRows)
|
||
// 清空选中
|
||
$('#subgrid').datagrid('clearChecked');
|
||
editIndex_sub = undefined;
|
||
});
|
||
}
|
||
|
||
|
||
function insertyf() {
|
||
if (checkchange()) {
|
||
alert('请先保存,再来导入应付费用!');
|
||
return;
|
||
}
|
||
var Fbsno = $('#b_id').val();
|
||
var Fdwid = $('#b_customer_id').val();
|
||
var Famount = $('#b_amount').val();
|
||
var Fmoney = $('#b_money_id').val();
|
||
/*if ((Fdwid== '')||(Fmoney== '')||(Famount==0)){
|
||
alert('请选填箱公司、单价、币种后,再来导入应付费用!');
|
||
return;
|
||
} */
|
||
|
||
/* var rows = $('#subgrid').datagrid('getChecked');
|
||
if (rows.length<=0){
|
||
var rows=$('#subgrid').datagrid('getRows');
|
||
//return false;
|
||
}; */
|
||
//alert(irow);
|
||
var rows = subgridRows;
|
||
var irow = subgridRows.length;
|
||
for (i = 0; i < irow; i++) {
|
||
var subid = rows[i].subid;
|
||
// alert(keyid);
|
||
if ((subid == '') || (subid == null) || (subid == undefined)) {
|
||
alert("请先保存!");
|
||
return;
|
||
}
|
||
}
|
||
|
||
var selarray = new Array();
|
||
var rows = $('#subgrid').datagrid('getChecked');
|
||
//alert(rows.length);
|
||
for (var i = rows.length - 1; i >= 0; i--) {
|
||
//for (var i = 0; i <= irow-1; i++){
|
||
if (rows[i].subid != '') {
|
||
selarray.push("'" + rows[i].subid + "'");
|
||
}
|
||
}
|
||
var sselarray = selarray.join(",");
|
||
var query = { selrows: selarray };
|
||
var keyID = 'xginsertfee_data' + generateUID();
|
||
localStorage.setItem(keyID, JSON.stringify(query));
|
||
|
||
var datadialog = parent.$('<div/>').dialog({
|
||
title: '费用导入操作',
|
||
width: 410,
|
||
height: 280,
|
||
id: 'cwdialog',
|
||
cache: false,
|
||
closeOnEscape: false,
|
||
// closable:true,
|
||
autoOpen: false,
|
||
top: 200,
|
||
//resizable:true,
|
||
content: '<iframe id="cwdialog" src="'
|
||
//+ 'jxg/insertcw_con.jsp?strid'+Fbsno+'&subid='+Fsubid //+'&iread='+iread
|
||
+ 'jxg/insertcw_con.jsp?id=' + Fbsno + "&type=应付" + "&hstype=买箱入库" + '&viewname=v_xg_buyin' + '&viewsub=xg_buyin_sub' + "&StoragekeyID=" + keyID//+ "&sselarray=" + encodeURI(sselarray)
|
||
+ '" allowTransparency="true" scrolling="auto" width="98%" height="98.3%" frameBorder="0"></iframe>',
|
||
modal: true,
|
||
onClose: function () {
|
||
$(this).remove();
|
||
loaddata_detail_sub('subgrid', 'v_xg_buyin_sub', strid, '');
|
||
$('#subgrid').datagrid('unselectAll');
|
||
$('#subgrid').datagrid('uncheckAll');
|
||
// loaddata(Fsubid);
|
||
// DoSearch();
|
||
//alert('111');
|
||
//getxzamount();
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
|
||
function createcon_pl() {
|
||
if (checkchange()) {
|
||
alert('请先保存,再来批量生成箱子!');
|
||
return;
|
||
}
|
||
if (document.getElementById("b_id").readOnly) {
|
||
} else {
|
||
alert('请先保存,再来批量生成箱子!');
|
||
return;
|
||
}
|
||
var Fbsno = $('#b_id').val();
|
||
var Fdwid = $('#b_customer_id').val();
|
||
var Famount = $('#b_amount').val();
|
||
var Fmoney = $('#b_money_id').val();
|
||
var selarray = new Array();
|
||
var sselarray = selarray.join(",");
|
||
var datadialog = parent.$('<div/>').dialog({
|
||
title: '批量生成操作',
|
||
width: 450,
|
||
height: 340,
|
||
id: 'cwdialog',
|
||
cache: false,
|
||
closeOnEscape: false,
|
||
// closable:true,
|
||
autoOpen: false,
|
||
top: 200,
|
||
//resizable:true,
|
||
content: '<iframe id="cwdialog" src="'
|
||
//+ 'jxg/insertcw_con.jsp?strid'+Fbsno+'&subid='+Fsubid //+'&iread='+iread
|
||
+ 'jxg/insertcon.jsp?id=' + Fbsno + "&hstype=买箱入库" + '&viewname=v_xg_buyin' + '&viewsub=xg_buyin_sub' + "&sselarray=" + encodeURI(sselarray)
|
||
+ '" allowTransparency="true" scrolling="auto" width="98%" height="98.3%" frameBorder="0"></iframe>',
|
||
modal: true,
|
||
onClose: function () {
|
||
$(this).remove();
|
||
loaddata_detail_sub('subgrid', 'v_xg_buyin_sub', strid, '');
|
||
$('#subgrid').datagrid('unselectAll');
|
||
$('#subgrid').datagrid('uncheckAll');
|
||
// loaddata(Fsubid);
|
||
// DoSearch();
|
||
//alert('111');
|
||
//getxzamount();
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
function showattach(o) {
|
||
var e = window.event || e;
|
||
if (e.stopPropagation) {
|
||
e.stopPropagation(); //阻止事件 冒泡传播
|
||
}
|
||
var selindex = $(o).attr('attr1');
|
||
var gridid = 'subgrid';
|
||
var rows = $("#" + gridid).datagrid("getRows");
|
||
var row = rows[selindex];
|
||
if (row.mx_conno != '' && row.mx_conno != undefined) {
|
||
getattachfile(row.mx_conno, 'xg_containerlib_files', 0);
|
||
} else {
|
||
alert('请确认箱号!');
|
||
}
|
||
}
|
||
|
||
|
||
// var gridname = 'subgrid';
|
||
// var $gridbody = $('#' + gridname).datagrid('getPanel').find('.datagrid-body');
|
||
// $gridbody.on('paste', myevent);
|
||
|
||
// var input = document.getElementById('auto_sub');
|
||
// input.addEventListener('paste', myevent);
|
||
|
||
function myevent(event) {
|
||
event.preventDefault();
|
||
|
||
var clipboardData = (event.originalEvent || event).clipboardData;
|
||
if (!clipboardData) return;
|
||
|
||
var gridname = 'subgrid';
|
||
var $grid = $('#' + gridname);
|
||
|
||
// 获取当前聚焦的列 field
|
||
var opts = $grid.datagrid('getColumnFields');
|
||
var fieldname_zx = '';
|
||
var colopts = [];
|
||
|
||
for (var j = 0; j < opts.length; j++) {
|
||
var editor = $grid.datagrid('getEditor', { index: editIndex_sub, field: opts[j] });
|
||
if (editor && editor.target.is(':focus')) {
|
||
fieldname_zx = opts[j]; // 找到聚焦列
|
||
}
|
||
|
||
var opt = $grid.datagrid('getColumnOption', opts[j]);
|
||
if (!opt.hidden) {
|
||
colopts.push(opts[j]); // 可见列
|
||
}
|
||
}
|
||
|
||
// 根据 fieldname_zx 找列索引
|
||
var colIndex = -1;
|
||
if (fieldname_zx) {
|
||
for (var k = 0; k < colopts.length; k++) {
|
||
if (colopts[k] === fieldname_zx) {
|
||
colIndex = k;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 获取当前行索引
|
||
var selrow = $grid.datagrid('getSelected');
|
||
var rowIndex = $grid.datagrid('getRowIndex', selrow);
|
||
if (colIndex === -1 || rowIndex === undefined || rowIndex < 0) {
|
||
$.messager.alert('提示', '请先点击要粘贴的单元格!');
|
||
return;
|
||
}
|
||
|
||
// 获取原始 ClipboardEvent
|
||
var clipboardData = event.originalEvent.clipboardData;
|
||
if (!clipboardData) return;
|
||
var data = clipboardData.getData('Text');
|
||
// 分行并过滤空行(避免最后多插入空行)
|
||
var datas = data.split("\n").filter(line => line.trim() !== "");
|
||
|
||
// 檢查
|
||
let allRows = $grid.datagrid('getData').firstRows || []
|
||
var selrow = allRows[rowIndex];
|
||
|
||
if (selrow && selrow.v_checkyx && selrow.v_checkyx === '是') {
|
||
$.messager.alert('提示', '箱号:' + (selrow.mx_conno || '') + ',已使用,不可修改!');
|
||
return;
|
||
}
|
||
|
||
// 提示
|
||
$.messager.progress({ title: '导入中', msg: '请稍候...' });
|
||
|
||
// ------------------------------
|
||
// 5️⃣ 构建 Worker 处理粘贴逻辑
|
||
// ------------------------------
|
||
var workerCode = `
|
||
function generateUUID() {
|
||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||
const r = Math.random() * 16 | 0;
|
||
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||
return v.toString(16);
|
||
});
|
||
}
|
||
|
||
self.onmessage = function(e){
|
||
const { datas, colopts, colIndex, rowIndex, allRows } = e.data;
|
||
const rowsCopy = allRows.slice();
|
||
|
||
for (let i = 0; i < datas.length; i++) {
|
||
let rowValues = datas[i].split("\\t");
|
||
|
||
// skip empty row
|
||
if (!rowValues.some(v => v.trim() !== "")) continue;
|
||
|
||
const targetIndex = rowIndex + i;
|
||
if (!rowsCopy[targetIndex]) rowsCopy[targetIndex] = {};
|
||
const jobj = rowsCopy[targetIndex];
|
||
|
||
if (!jobj.mx_xh) {
|
||
jobj.mx_xh = generateUUID();
|
||
}
|
||
if (jobj.v_checkyx === '是') {
|
||
self.postMessage({ error: '箱号:' + (jobj.mx_conno||'') + ',已使用,不可修改!' });
|
||
return;
|
||
}
|
||
|
||
for (let j = 0; j < rowValues.length; j++) {
|
||
let colfieldname = colopts[colIndex + j];
|
||
if (!colfieldname) continue;
|
||
|
||
let colvalue = rowValues[j];
|
||
if (typeof colvalue === "string") {
|
||
colvalue = colvalue.replace(new RegExp("[\\\\r\\\\n]+", "g"), "");
|
||
}
|
||
jobj[colfieldname] = colvalue;
|
||
if(colfieldname === 'mx_keyid') jobj['mx_keyid'] = '';
|
||
}
|
||
|
||
rowsCopy[targetIndex] = jobj;
|
||
}
|
||
|
||
self.postMessage({ rows: rowsCopy });
|
||
};
|
||
`;
|
||
|
||
// ------------------------------
|
||
// 6️⃣ 启动 Worker
|
||
// ------------------------------
|
||
var blob = new Blob([workerCode], { type: "application/javascript" });
|
||
var worker = new Worker(URL.createObjectURL(blob));
|
||
|
||
worker.postMessage({ datas, colopts, colIndex, rowIndex, allRows });
|
||
|
||
worker.onmessage = function (e) {
|
||
if (e.data.error) {
|
||
$.messager.alert('提示', e.data.error);
|
||
$.messager.progress('close');
|
||
worker.terminate();
|
||
return;
|
||
}
|
||
|
||
var newAllRows = e.data.rows;
|
||
|
||
// 更新 datagrid 数据
|
||
$grid.datagrid('loadData', newAllRows);
|
||
|
||
// ------------------------------
|
||
// 7️⃣ 恢复编辑状态,处理 textbox/val
|
||
// ------------------------------
|
||
// for (var i = 0; i < newAllRows.length; i++) {
|
||
// $grid.datagrid('beginEdit', i);
|
||
// for (var j = 0; j < colopts.length; j++) {
|
||
// var field = colopts[j];
|
||
// var ed = $grid.datagrid('getEditor', { index: i, field: field });
|
||
// if (ed) {
|
||
// var val = newAllRows[i][field];
|
||
// if (ed.target.next().attr('class') === 'textbox') {
|
||
// ed.target.textbox('setValue', val);
|
||
// } else {
|
||
// ed.target.val(val);
|
||
// }
|
||
// }
|
||
// }
|
||
// }
|
||
|
||
$.messager.progress('close');
|
||
worker.terminate();
|
||
};
|
||
}
|
||
|
||
function myevent_old(event) {
|
||
// 添加到事件对象中的访问系统剪贴板的接口
|
||
//endEditing_sub();
|
||
var gridname = 'subgrid';
|
||
var clipboardData = event.clipboardData,
|
||
i = 0,
|
||
items, item, types;
|
||
data = clipboardData.getData('Text');
|
||
var datas = data.split("\n");
|
||
var opts = $('#' + gridname).datagrid('getColumnFields');
|
||
var fieldname_zx = '';
|
||
var colopts = new Array();
|
||
for (var j = 0; j < opts.length; j++) {
|
||
var editor = $('#' + gridname).datagrid('getEditor',
|
||
{
|
||
index: editIndex_sub,
|
||
field: opts[j]
|
||
}
|
||
);
|
||
if (editor) {
|
||
if (editor.target.is(":focus")) {
|
||
fieldname_zx = opts[j];
|
||
}
|
||
}
|
||
var opt = $('#' + gridname).datagrid('getColumnOption', opts[j]);
|
||
if (!opt.hidden) {
|
||
colopts.push(opts[j]);
|
||
}
|
||
}
|
||
var k = 1;
|
||
if ((fieldname_zx != '') && (fieldname_zx != undefined)) {
|
||
for (k = 0; k < colopts.length; k++) {
|
||
if (colopts[k] == fieldname_zx) {
|
||
// alert(k);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
var selrow = $('#' + gridname).datagrid('getSelected');
|
||
var rowindex = $('#' + gridname).datagrid('getRowIndex', selrow);
|
||
// $.messager.progress({
|
||
// title:'导入中',
|
||
// msg:'导入中...'
|
||
// });
|
||
|
||
for (var i = 0; i < datas.length; i++) {
|
||
var row = datas[i].split("\t");
|
||
// alert(row);
|
||
if (row != '') {
|
||
if (endEditing_sub()) {
|
||
var rowlen = $('#' + gridname).datagrid('getRows').length;
|
||
var rows = $('#' + gridname).datagrid('getRows');
|
||
// alert(rowlen);
|
||
if ((rowlen >= rowindex + i) && (rowlen > 0) && (rowindex != -1)) {
|
||
editIndex_sub = rowindex + i;
|
||
} else {
|
||
$('#' + gridname).datagrid('appendRow', {});
|
||
editIndex_sub = $('#' + gridname).datagrid('getRows').length - 1;
|
||
}
|
||
//rows[i].v_checkyx!='是'
|
||
var Fcheckyx = rows[editIndex_sub].v_checkyx;
|
||
var Fconno = rows[editIndex_sub].mx_conno;
|
||
if (Fcheckyx == '是') {
|
||
alert('箱号:' + Fconno + ',已使用,不可修改!');
|
||
return;
|
||
}
|
||
/*$('#'+gridname).datagrid('beginEdit', editIndex_sub);
|
||
Fcheckyx=$('#subgrid').datagrid('getRows')[editIndex_sub].v_checkyx;
|
||
Fconno=$('#subgrid').datagrid('getRows')[editIndex_sub].mx_conno;
|
||
if (Fcheckyx=='是'){
|
||
alert('箱号:'+Fconno+',已使用,不可修改!');
|
||
return;
|
||
}*/
|
||
var jobj = {};
|
||
for (var j = 0; j < row.length; j++) {
|
||
/*var colvalue=row[j];
|
||
var colfieldname=colopts[k+j];
|
||
$('#'+gridname).datagrid('beginEdit', editIndex_sub);
|
||
var ed=$('#'+gridname).datagrid('getEditor', {index : editIndex_sub,field : colfieldname});
|
||
if(ed){
|
||
ed.target.val(colvalue);
|
||
}*/
|
||
var colvalue = row[j];
|
||
var colfieldname = colopts[k + j];
|
||
strval = app.jsonToString(colvalue);
|
||
if (strval.indexOf("\\r\\n") > -1) {
|
||
strval = strval.substring(0, strval.length - 5) + '"';
|
||
strval = eval('(' + strval + ')')
|
||
colvalue = strval;
|
||
}
|
||
//jobj[colfieldname]=colvalue;
|
||
rows[editIndex_sub][colfieldname] = colvalue;
|
||
if (colfieldname == 'v_mx_atwhere_name') {
|
||
// console.log(colvalue);
|
||
var searchsql = " b_name='" + colvalue + "'";
|
||
var tmpjson = loaddatas('b_othercompany', searchsql, '', '');
|
||
if (tmpjson.length > 0) {
|
||
var Fatwhereid = tmpjson[0].b_id
|
||
}
|
||
//jobj['mx_atwhere']=Fatwhereid;
|
||
rows[editIndex_sub].mx_atwhere = Fatwhereid;
|
||
}
|
||
//if (colfieldname=='mx_keyid'){
|
||
// jobj['mx_keyid']='';
|
||
// rows[editIndex_sub].mx_keyid='';
|
||
//}
|
||
// $('#'+gridname).datagrid('beginEdit', editIndex_sub);
|
||
|
||
//if (colfieldname=='mx_conno'){
|
||
//Fcheckyx=$('#subgrid').datagrid('getRows')[editIndex_sub].v_checkyx
|
||
// Fconno=$('#subgrid').datagrid('getRows')[editIndex_sub].mx_conno
|
||
// if (Fcheckyx='是'){
|
||
// alert('箱号:'+Fconno+',已使用,不可修改!');
|
||
// return;
|
||
//}
|
||
/*var ed=$('#'+gridname).datagrid('getEditor', {index : editIndex_sub,field : colfieldname});
|
||
if(ed){
|
||
if(ed.target.next().attr("class") == "textbox"){
|
||
ed.target.textbox('setValue',colvalue);
|
||
}else{
|
||
ed.target.val(colvalue);
|
||
}
|
||
}*/
|
||
}
|
||
}
|
||
/*$('#'+gridname).datagrid('updateRow',{
|
||
index: editIndex_sub,
|
||
row: jobj
|
||
}); */
|
||
$('#' + gridname).datagrid('refreshRow', editIndex_sub);
|
||
}
|
||
|
||
}
|
||
endEditing_sub();
|
||
//loadcon();
|
||
// $.messager.progress('close');
|
||
}
|
||
|
||
function printtoexcel() {
|
||
Save_Excel('subgrid');
|
||
}
|
||
|
||
function showsortmenu(event) {
|
||
var parObj = $("#more");
|
||
var y = parObj.offset().top;
|
||
var x = parObj.offset().left;
|
||
|
||
$('#sortmenu').menu('show', {
|
||
left: x,
|
||
top: y + 25
|
||
});
|
||
}
|
||
|
||
function importcwexcel() {
|
||
var Fbsno = $('#b_id').val();
|
||
if (checkchange()) {
|
||
alert('请先保存,再来导入应付费用!');
|
||
return;
|
||
}
|
||
var rows = subgridRows;
|
||
var irow = $('#subgrid').data('allRows').length || [].length;
|
||
for (i = 0; i < irow; i++) {
|
||
var subid = rows[i].subid;
|
||
// alert(keyid);
|
||
if ((subid == '') || (subid == null) || (subid == undefined)) {
|
||
alert("请先保存!");
|
||
return;
|
||
}
|
||
}
|
||
var Vtable = 'v_tj_xg_sub'; //视图,用来取field(列名)的;
|
||
var FTable = 'bs_business_cw'; //要更新的表
|
||
var PPfield = '[mx_conno]'; //粘贴复制的内容和数据库表中的内容 用来匹配的字段
|
||
var importField = '[mx_conno,mx_date8,b_shipingdate,mx_bz10,mx_msg,mx_date2,mx_date6,mx_msg_gw,mx_date3,mx_bz11,mx_date4]'; //导入的字段,不包含在内的字段无法导入.
|
||
var parentfrm = self.name;
|
||
parent.$('<div/>').dialog({
|
||
title: '批量导入费用操作',
|
||
width: 1080,
|
||
height: 600,
|
||
id: 'jddialog',
|
||
top: 50,
|
||
onClose: function () {
|
||
$(this).remove();
|
||
//DoSearch();
|
||
},
|
||
content: '<iframe id="jddialog" name="jddialog" src="'
|
||
+ 'jxg/importexcelcw_con.jsp?FTable=' + FTable + '&PPfield=' + PPfield + '&parentfrm=' + parentfrm
|
||
+ '&Vtable=' + Vtable + '&importField=' + importField + "&hstype=买箱入库" + '&Fid=' + Fbsno
|
||
+ '" allowTransparency="true" scrolling="auto" width="100%" height="99.3%" frameBorder="0" name=""></iframe>',
|
||
modal: true
|
||
});
|
||
}
|
||
|
||
function showconlog() {
|
||
var sid = $('#b_id').val();
|
||
Ftype = "箱号";
|
||
//Ftype=type;
|
||
var url;
|
||
url = "jxg/xgcondellog.jsp?businessid=" + sid + '&type=' + Ftype;
|
||
if (url != undefined) {
|
||
var datadialog = parent.$('<div/>').dialog({
|
||
title: '箱子删除日志',
|
||
width: 680,
|
||
height: 500,
|
||
content: '<iframe id="" src="'
|
||
+ url
|
||
+ '" allowTransparency="true" scrolling="auto" width="100%" height="99.2%" frameBorder="0" name=""></iframe>',
|
||
modal: true
|
||
});
|
||
}
|
||
}
|
||
|
||
|
||
|
||
function showlog(type, id) {
|
||
var url;
|
||
url = "jxg/xgconlog.jsp?businessid=" + id;
|
||
if (url != undefined) {
|
||
var datadialog = parent.$('<div/>').dialog({
|
||
title: '箱子修改日志',
|
||
width: 950,
|
||
height: 600,
|
||
content: '<iframe id="" src="'
|
||
+ url
|
||
+ '" allowTransparency="true" scrolling="auto" width="100%" height="99.2%" frameBorder="0" name=""></iframe>',
|
||
modal: true
|
||
});
|
||
}
|
||
|
||
}
|
||
|
||
function getappendconFrm() {
|
||
$('#CategoryFrm').window({
|
||
width: 260,
|
||
height: 200,
|
||
left: 520,
|
||
top: 200,
|
||
title: '批量选择箱子',
|
||
collapsible: false,
|
||
minimizable: false,
|
||
maximizable: false,
|
||
modal: true,
|
||
href: 'jxg/selectcon_pl.jsp'
|
||
});
|
||
}
|
||
function selectcon_pl() {
|
||
/*if (checkchange()){
|
||
alert('请先保存,再来生成箱子!');
|
||
return;
|
||
} */
|
||
getappendconFrm();
|
||
$("#CategoryFrm").window({
|
||
onLoad: function () {
|
||
/*setAutoCompleteSimple('#mx_con_size',[["20'"],["40'"],["45'"]]);
|
||
setAutoComplete('#mx_con_type_id', 'b_con_type', 'b_name','b_id','');
|
||
setAutoCompleteSimple('#mx_cztype',[['过磅称重法M1'],['累计相加称重法M2']]);
|
||
setAutoCompleteSimple('#mx_con_kz',[['E'],['F']]); */
|
||
},
|
||
onClose: function () {
|
||
if (CategoryFrmshowmodal) {
|
||
var e = window.event || e;
|
||
if (e.stopPropagation) {
|
||
e.stopPropagation(); //阻止事件 冒泡传播
|
||
}
|
||
isSave = true;
|
||
var fatherid = $("#b_id").val();
|
||
|
||
var Fcontype = $('#mx_con_type_id').val();
|
||
var Fbegin = Number($('#b_begin').val());
|
||
var Fend = Number($('#b_end').val());
|
||
if ((Fbegin == '') || (Fbegin == 0) || (Fend == '') || (Fend == 0)) {
|
||
alert('该起止不能为空!'); //、箱量
|
||
return;
|
||
}
|
||
|
||
var irow = $('#subgrid').datagrid('getData').firstRows.length || 0;
|
||
for (i = Fbegin - 1; i < Fend; i++) {
|
||
if (i < irow) {
|
||
$('#subgrid').datagrid('checkRow', i);
|
||
}
|
||
}
|
||
$("#subgrid").datagrid('scrollTo', Fbegin)
|
||
}
|
||
}
|
||
})
|
||
}
|
||
// 字母 A~Z 的值映射(与 Java 版 ConCharValues 一致)
|
||
const ConCharValues = [
|
||
10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25,
|
||
26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38
|
||
];
|
||
|
||
function getPow2(n) {
|
||
// 使用位运算减少开销(比 Math.pow 更快)
|
||
return 1 << n;
|
||
}
|
||
|
||
|
||
function checkConNo(conno) {
|
||
if (!conno || conno.length !== 11) {
|
||
return "集装箱号" + conno + "不正确,请输入11位集装箱号";
|
||
}
|
||
|
||
const sqz = conno.substring(0, 4); // 前四位字母
|
||
const szz = conno.substring(4, 10); // 中间六位数字
|
||
const shz = conno.substring(10, 11); // 校验位
|
||
|
||
// ===== 前四位必须 A~Z =====
|
||
for (let i = 0; i < 4; i++) {
|
||
const code = conno.charCodeAt(i);
|
||
if (code < 65 || code > 90) {
|
||
return "集装箱号" + conno + "不正确,前四位应该是字符";
|
||
}
|
||
}
|
||
|
||
// ===== 后六位必须为数字 =====
|
||
for (let i = 4; i < 10; i++) {
|
||
const code = conno.charCodeAt(i);
|
||
if (code < 48 || code > 57) {
|
||
return "集装箱号" + conno + "不正确,后七位应该是数字";
|
||
}
|
||
}
|
||
|
||
// ===== 校验位必须数字 =====
|
||
const checkDigit = conno.charCodeAt(10);
|
||
if (checkDigit < 48 || checkDigit > 57) {
|
||
return "集装箱号" + conno + "不正确,后七位应该是数字";
|
||
}
|
||
const checkNum = checkDigit - 48;
|
||
|
||
// ===== 计算校验值 =====
|
||
let sumValue = 0;
|
||
|
||
// 前四位 A-Z
|
||
for (let i = 0; i < 4; i++) {
|
||
const letterIndex = conno.charCodeAt(i) - 65; // A=0
|
||
sumValue += ConCharValues[letterIndex] * getPow2(i);
|
||
}
|
||
|
||
// 后六位数字
|
||
for (let i = 4; i < 10; i++) {
|
||
const num = conno.charCodeAt(i) - 48;
|
||
sumValue += num * getPow2(i);
|
||
}
|
||
|
||
// ===== 模 11 校验 =====
|
||
const mod = sumValue % 11;
|
||
|
||
if (mod !== 10) {
|
||
if (mod !== checkNum) {
|
||
return "箱号" + conno + "校验不正确";
|
||
}
|
||
} else {
|
||
if (checkNum !== 0) {
|
||
return "箱号" + conno + "校验不正确";
|
||
}
|
||
}
|
||
|
||
return "OK";
|
||
}
|
||
|
||
</script>
|
||
</body>
|
||
</html> |