diff --git a/README.md b/README.md
index ae3650dd..ae60b9ae 100644
--- a/README.md
+++ b/README.md
@@ -1,22 +1,16 @@
# 项目总述
* 很多人说华夏ERP(英文名:jshERP)是目前唯一完整开源的进销存系统
* 虽然目前只有进销存+财务的功能,但后面将会推出ERP的全部功能,大家一起努力吧
-* 部署如有问题请联系QQ:960596000,
-* 欢迎加入乾坤平台-华夏ERP群,群号码:693725296
-扫码加群:
-
-* [交流社区](https://qiankunpingtai.cn/domain/%E8%BF%9B%E9%94%80%E5%AD%98)
-* 联系方式二:QQ:752718920,交流群二,群号码:120725710
* 商务合作-请联系QQ:514869858,技术交流-请联系QQ:752718920
* 欢迎加入华夏ERP交流QQ群,群1:120725710(满)、群2:732152262
* 系统的默认超管账户:admin,默认租户账号:jsh,默认密码均为:123456
* 部署如遇到困难请参考Wiki文档 **https://gitee.com/jishenghua/JSH_ERP/wikis/pages**
-* **[本系统演示地址一](http://erp.qkpt.top/login.html) 账号:jsh,密码:123456,欢迎登录(如需试用,欢迎注册)**
-* **[本系统演示地址二](http://www.huaxiaerp.com)**
+* 官网地址:[http://www.huaxiaerp.com](https://www.huaxiaerp.com),测试账号:jsh,密码:123456,**(如需长期使用,欢迎注册)**
+
# 定制服务
* 如有ERP **私人定制** 需求,请将需求整理成文档,发给邮箱: **514869858@qq.com** ,我会及时回复哒
-# 开发初衷
+# 开发初衷
* 华夏ERP立志为中小企业提供开源好用的ERP软件,降低企业的信息化成本
* 个人开发者也可以使用华夏ERP进行二次开发,加快完成开发任务
* 初学JAVA的小伙伴可以下载源代码来进行学习交流
@@ -48,22 +42,22 @@
# 系统美图
* 首页
-
+
* 零售管理
-
+
* 采购管理
-
+
* 销售管理
-
+
* 仓库管理
-
+
* 财务管理
-
+
* 报表查询
-
+
* 商品管理
-
+
* 基本资料
-
+
* 系统管理
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/erp_web/js/pages/financial/advance_in.js b/erp_web/js/pages/financial/advance_in.js
deleted file mode 100644
index 5fd73939..00000000
--- a/erp_web/js/pages/financial/advance_in.js
+++ /dev/null
@@ -1,955 +0,0 @@
-//初始化界面
-var listType = "收预付款";
-var itemType = true; //隐藏当前列
-var moneyType = false; //显示当前列
-var payTypeTitle = "无标题";
-var inOrOut = "";
-var amountNum = "SYF";
-var organUrl = "/supplier/findBySelect_retail"; //散户接口
-var listTitle='收预付款列表';
-$(function(){
- initSystemData_person(); //经手人数据
- initSelectInfo_person(); //经手人信息
- initSystemData_account(); //账户数据
- initSelectInfo_account(); //账户信息
- initSupplier(); //供应商
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
- $("#searchBtn").click();
-});
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null)
- {
- options = "";
- for(var i = 0 ;i < accountList.length; i++)
- {
- var account = accountList[i];
- options += '';
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//初始化单位信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- formatter: function(row){
- var opts = $(this).combobox('options');
- if(row[opts.textField]!=="非会员") {
- return row[opts.textField];
- }
- }
- });
-}
-
-//获取财务员
-function initSystemData_person(){
- var type = "财务员";
- $.ajax({
- type:"get",
- url: "/person/getPersonByType",
- data: {
- type: type
- },
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- personList = res.data.personList;
- }
- }
- });
-}
-//获取财务员
-function initSelectInfo_person(){
- var options = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="财务员")
- {
- options += '';
- }
- }
- $("#HandsPersonId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#accountHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- var organNameTitle = "付款会员";
- var organNameHidden = false;
- $('#tableData').datagrid({
- //width:700,
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //fitColumns:true,
- //单击行是否选中
- //checkOnSelect : false,
- pagination: true,
- //交替出现背景
- striped : true,
- //loadFilter: pagerFilter,
- pageSize: 5,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:90,formatter:function(value, rec,index) {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/7 10:48
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js
- */
- var str = '';
- var orgId = rec.organid ? rec.organid : 0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { field: 'organid',width:5, hidden:true},
- { title: organNameTitle,field: 'organname',width:140,hidden:organNameHidden},
- { title: '单据编号',field: 'billno',width:140},
- { title: '经手人',field: 'handspersonname',width:80},
- { title: '单据时间 ',field: 'billtime',width:140},
- { title: '合计',field: 'totalprice',width:80},
- { title: '备注',field: 'remark',width:100}
- ]],
- toolbar:[
- {
- id:'addAccountHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addAccountHead();
- }
- },
- {
- id:'deleteAccountHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteAccountHead();
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化表格数据-明细列表-编辑状态
-function initTableData_account(type,TotalPrice){
- $('#accountData').datagrid({
- height:280,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: payTypeTitle,field: 'InOutItemId',width:230,hidden:itemType,
- formatter:function(value,row,index){
- return row.InOutItemName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'InOutItemName',
- method:'get',
- url: "/inOutItem/findBySelect?type=" + inOrOut
- }
- }
- },
- { title: '账户名称',field: 'AccountId',width:230,hidden:moneyType,
- formatter:function(value,row,index){
- return row.AccountName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'AccountName',
- method:'get',
- url: "/account/findBySelect"
- }
- }
- },
- { title: '金额',field: 'EachAmount',editor:'validatebox',width:70},
- { title: '备注',field: 'Remark',editor:'validatebox',width:150}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- removeit(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/accountItem/getDetailList',
- data: {
- headerId: accountHeadID
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var EachAmount = 0;
- if(type === "edit") {
- EachAmount = TotalPrice;
- }
- var array = [];
- array.push({
- "EachAmount": EachAmount
- });
- data.footer = array;
- $("#accountData").datagrid('loadData',data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-
-//初始化表格数据-明细列表-查看状态
-function initTableData_account_show(TotalPrice){
- $('#accountDataShow').datagrid({
- height:280,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { title: payTypeTitle, field: 'InOutItemName', width:230, hidden:itemType},
- { title: '账户名称', field: 'AccountName', width:230, hidden:moneyType},
- { title: '金额',field: 'EachAmount',width:70},
- { title: '备注',field: 'Remark',width:150}
- ]],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/accountItem/getDetailList',
- data: {
- headerId: accountHeadID
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var EachAmount = TotalPrice;
- var array = [];
- array.push({
- "EachAmount": EachAmount
- });
- data.footer = array;
- $("#accountDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showAccountHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除财务信息
-function deleteAccountHead(accountHeadID, thisOrganId, totalPrice){
- $.messager.confirm('删除确认','确定要删除此财务信息吗?',function(r)
- {
- if (r)
- {
- $.ajax({
- type:"post",
- url: "/accountHead/batchDeleteAccountHeadByIds",
- dataType: "json",
- data:{
- ids: accountHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=accountHeadID;
- jsondata.deleteType='2';
- var type='single';
- batDeleteAccountHeadForceConfirm(res,"/accountHead/batchDeleteAccountHeadByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
-
- //更新会员的预收款信息
- if(listType === "收预付款"){
- $.ajax({
- type:"post",
- url: "/supplier/updateAdvanceIn",
- dataType: "json",
- data:{
- supplierId: thisOrganId, //会员id
- advanceIn: 0-totalPrice //删除时同时删除用户的预付款信息
- },
- success: function(res){
- if(res && res.code === 200) {
- //保存会员预收款成功
- }
- },
- error: function(){
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- }
- });
-}
-
-//批量删除财务信息
-function batDeleteAccountHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条财务信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1)
- {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
-
- //批量删除
- $.ajax({
- type:"post",
- url: "/accountHead/batchDeleteAccountHeadByIds",
- dataType: "json",
- async : false,
- data: ({
- ids : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=ids;
- jsondata.deleteType='2';
- var type='batch';
- batDeleteAccountHeadForceConfirm(res,"/accountHead/batchDeleteAccountHeadByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
- //批量更新会员的预收款信息
- for(var i = 0;i < row.length; i ++) {
- if(listType === "收预付款"){
- $.ajax({
- type:"post",
- url: "/supplier/updateAdvanceIn",
- dataType: "json",
- data:{
- supplierId: row[i].organid, //会员id
- advanceIn: 0 - row[i].totalprice //删除时同时删除用户的预付款信息
- },
- success: function(res){
- if(res && res.code === 200) {
- //保存会员预收款成功
- }
- },
- error: function(){
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- }
- }
- });
- }
-}
-/**
- * 确认强制删除
- * */
-function batDeleteAccountHeadForceConfirm(res,url,jsondata) {
- $.messager.confirm('删除确认', res.msg, function (r) {
- if (r) {
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: (jsondata),
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- if(type=='batch'){
- $(":checkbox").attr("checked", false);
- }
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-
-//增加
-function addAccountHead(){
- $('#accountHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#BillTime").val(thisDateTime);
- var thisNumber = getNowFormatDateNum(); //根据时间生成编号
- $("#BillNo").val(amountNum + thisNumber).focus();
- var addTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgAccountHead = "";
- accountHeadID = 0;
- initTableData_account("add"); //明细列表
- reject(); //撤销下、刷新材料列表
- url = '/accountHead/addAccountHeadAndDetail';
-
- //收预付款单据支持刷卡功能
- if(listType == "收预付款") {
- //当会员卡号长度超过10位后,自动点击下拉框,用于兼容刷卡器
- $("#OrganId").next().find("input").off("keyup").on("keyup",function(){
- if($(this).val().length === 10){
- setTimeout(function(){
- $(".combo-panel .combobox-item-selected").click();
- },500);
- }
- });
- }
-}
-
-//编辑信息
-function editAccountHead(index){
- // var accountHeadInfo = accountHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#BillNo").val(rowsdata.billno);
- $("#BillTime").val(rowsdata.billtime);
- $("#Remark").val(rowsdata.remark);
- $("#AccountId").val(rowsdata.accountid);
- $('#OrganId').combobox('setValue', rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#ChangeAmount").val(rowsdata.changeamount);
- var TotalPrice = rowsdata.totalprice;
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于收预付款
- var editTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- accountHeadID = rowsdata.id;
-
- initTableData_account("edit",TotalPrice); //明细列表
- reject(); //撤销下、刷新列表
- url = '/accountHead/updateAccountHeadAndDetail?id=' + rowsdata.id;
-}
-
-//查看信息
-function showAccountHead(index){
- // var accountHeadInfo = accountHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#BillNoShow").text(rowsdata.billno);
- $("#BillTimeShow").text(rowsdata.billtime);
- $("#RemarkShow").text(rowsdata.remark);
- $("#AccountIdShow").text(rowsdata.accountname);
- $('#OrganIdShow').text(rowsdata.organname);
- $("#HandsPersonIdShow").text(rowsdata.handspersonname);
- $("#ChangeAmountShow").text(rowsdata.rowsdata==undefined?'0':rowsdata.rowsdata);
- var TotalPrice = rowsdata.totalprice;
- var showTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlgShow').dialog('open').dialog('setTitle','
查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- accountHeadID = rowsdata.id;
- initTableData_account_show(TotalPrice); //明细列表-查看状态
-}
-
-//绑定操作事件
-function bindEvent(){
- //搜索处理
- $("#searchBtn").unbind().bind({
- click:function()
- {
- showAccountHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh', {
- pageNumber:1,
- pageSize:initPageSize
- });
- }
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- $("#searchBillNo").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //保存信息
- $("#saveAccountHead").off("click").on("click", function () {
- if(!$('#accountHeadFM').form('validate')){
- return;
- } else {
- if (!$('#HandsPersonId').val()) {
- $.messager.alert('提示', '请选择经手人!', 'warning');
- return;
- }
- if (!$('#OrganId').combobox('getValue')) {
- $.messager.alert('提示', '请选择付款会员!', 'warning');
- return;
- }
- var OrganId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val());
- var TotalPrice = $("#accountHeadFM .datagrid-footer [field='EachAmount'] div").text();
- OrganId = $('#OrganId').combobox('getValue');
- //更新会员的预收款信息
- var advanceIn = 0; //预付款金额
- if (accountHeadID) {
- advanceIn = TotalPrice - preTotalPrice; //修改时,预付款=合计金额-加载金额
- }
- else {
- advanceIn = TotalPrice; //新增时,预付款=合计金额
- }
- $.ajax({
- type: "post",
- url: "/supplier/updateAdvanceIn",
- dataType: "json",
- data: {
- supplierId: OrganId,
- advanceIn: advanceIn
- },
- success: function (res) {
- if (res && res.code === 200) {
- //保存会员预收款成功
- }
- },
- error: function () {
- $.messager.alert('提示', '保存信息异常,请稍后再试!', 'error');
- return;
- }
- });
- saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId);
- }
- });
-
- //打印单据
- $("#printAccountHeadShow").off("click").on("click",function(){
- var tableString = $("#accountHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event)
- {
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="BillNo"||obj.id=="BillTime"))
- {
- $("#saveAccountHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchBillNo"))
- {
- $("#searchBtn").click();
- }
- });
-}
-
-function showAccountHeadDetails(pageNo,pageSize){
- $.ajax({
- type:"get",
- url: "/accountHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- billNo: $.trim($("#searchBillNo").val()),
- beginTime: $("#searchBeginTime").val(),
- endTime: $("#searchEndTime").val()
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#accountHeadFM .datagrid-body");
- var footer =$("#accountHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
-
- //修改金额,自动计算单价和合计
- body.find("[field='EachAmount']").find(input).off("keyup").on("keyup",function(){
- var TotalPrice = 0;
- var EachAmount =$(this).val()-0; //金额
- body.find("[field='EachAmount']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + EachAmount;
- footer.find("[field='EachAmount']").find("div").text((TotalPrice).toFixed(2));
- });
- },500);
-}
-
-//结束编辑
-function endEditing() {
- var edField = "";
- if(!itemType){
- edField = "InOutItemId";
- edName = "InOutItemName";
- }
- else {
- edField = "AccountId";
- edName = "AccountName";
- }
- if (editIndex == undefined) { return true }
- if ($('#accountData').datagrid('validateRow', editIndex)) {
- var ed = $('#accountData').datagrid('getEditor', {index: editIndex, field: edField});
- var textName =null;
- if($(ed.target)){
- textName = $(ed.target).combobox('getText');
- }
- $('#accountData').datagrid('getRows')[editIndex][edName] = textName;
- $('#accountData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#accountData').datagrid('selectRow', index)
- .datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#accountData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append() {
- if (endEditing()) {
- $('#accountData').datagrid('appendRow', {});
- editIndex = $('#accountData').datagrid('getRows').length - 1;
- $('#accountData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function removeit() {
- if (editIndex == undefined) { return }
- $('#accountData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#accountData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData() {
- var row = $('#accountData').datagrid('getRows');
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if(!itemType){
- if (row[i].InOutItemId == "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- else{
- if (row[i].AccountId == "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-function saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId) {
- if (editIndex != undefined) {
- $('#accountData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- if (!CheckData())
- return false;
- var inserted = $("#accountData").datagrid('getChanges', "inserted");
- var deleted = $("#accountData").datagrid('getChanges', "deleted");
- var updated = $("#accountData").datagrid('getChanges', "updated");
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: {
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- info : JSON.stringify({
- Type: listType,
- BillNo: $.trim($("#BillNo").val()),
- BillTime: $.trim($("#BillTime").val()),
- AccountId: $.trim($("#AccountId").val()),
- ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
- TotalPrice: TotalPrice, //合计
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Remark: $.trim($("#Remark").val())
- }),
- listType: listType
- },
- success: function (tipInfo)
- {
- if (tipInfo) {
- $.messager.alert('提示','保存成功!','info');
- $('#accountHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showAccountHeadDetails(opts.pageNumber, opts.pageSize);
- }
- else{
-
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- error: function (XmlHttpRequest, textStatus, errorThrown)
- {
- $.messager.alert('提示',XmlHttpRequest.responseText,'error');
- }
- });
-}
-
-
-
-
-
-
diff --git a/erp_web/js/pages/financial/giro.js b/erp_web/js/pages/financial/giro.js
deleted file mode 100644
index a36e1e36..00000000
--- a/erp_web/js/pages/financial/giro.js
+++ /dev/null
@@ -1,856 +0,0 @@
-//初始化界面
-var listTitle="转账单列表";
-var listType = "转账";
-var itemType = true; //隐藏当前列
-var moneyType = false; //显示当前列
-var payTypeTitle = "无标题";
-var inOrOut = "";
-var organUrl = "/supplier/findBySelect_cus"; //客户接口
-var amountNum = "ZZ";
-$(function(){
- initSystemData_person(); //经手人数据
- initSelectInfo_person(); //经手人信息
- initSystemData_account(); //账户数据
- initSelectInfo_account(); //账户信息
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
- $("#searchBtn").click();
-});
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null)
- {
- options = "";
- for(var i = 0 ;i < accountList.length; i++)
- {
- var account = accountList[i];
- options += '';
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-
-//获取财务员
-function initSystemData_person(){
- var type = "财务员";
- $.ajax({
- type:"get",
- url: "/person/getPersonByType",
- data: {
- type: type
- },
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- personList = res.data.personList;
- }
- }
- });
-}
-//获取财务员
-function initSelectInfo_person(){
- var options = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="财务员")
- {
- options += '';
- }
- }
- $("#HandsPersonId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#accountHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- var organNameTitle = "";
- var organNameHidden = true;
- $('#tableData').datagrid({
- //width:700,
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //fitColumns:true,
- //单击行是否选中
- //checkOnSelect : false,
- pagination: true,
- //交替出现背景
- striped : true,
- //loadFilter: pagerFilter,
- pageSize: 5,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:90,formatter:function(value, rec,index) {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/7 10:48
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js
- */
- var str = '';
- var orgId = rec.organid ? rec.organid : 0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { field: 'organid',width:5, hidden:true},
- { title: organNameTitle,field: 'organname',width:140,hidden:organNameHidden},
- { title: '单据编号',field: 'billno',width:140},
- { title: '经手人',field: 'handspersonname',width:80},
- { title: '单据时间 ',field: 'billtime',width:140},
- { title: '合计',field: 'totalprice',width:80},
- { title: '备注',field: 'remark',width:100}
- ]],
- toolbar:[
- {
- id:'addAccountHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addAccountHead();
- }
- },
- {
- id:'deleteAccountHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteAccountHead();
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化表格数据-明细列表-编辑状态
-function initTableData_account(type,TotalPrice){
- $('#accountData').datagrid({
- height:280,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: payTypeTitle,field: 'InOutItemId',width:230,hidden:itemType,
- formatter:function(value,row,index){
- return row.InOutItemName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'InOutItemName',
- method:'get',
- url: "/inOutItem/findBySelect?type=" + inOrOut
- }
- }
- },
- { title: '账户名称',field: 'AccountId',width:230,hidden:moneyType,
- formatter:function(value,row,index){
- return row.AccountName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'AccountName',
- method:'get',
- url: "/account/findBySelect"
- }
- }
- },
- { title: '金额',field: 'EachAmount',editor:'validatebox',width:70},
- { title: '备注',field: 'Remark',editor:'validatebox',width:150}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- removeit(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/accountItem/getDetailList',
- data: {
- headerId: accountHeadID
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var EachAmount = 0;
- if(type === "edit") {
- EachAmount = TotalPrice;
- }
- var array = [];
- array.push({
- "EachAmount": EachAmount
- });
- data.footer = array;
- $("#accountData").datagrid('loadData',data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-
-//初始化表格数据-明细列表-查看状态
-function initTableData_account_show(TotalPrice){
- $('#accountDataShow').datagrid({
- height:280,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { title: payTypeTitle, field: 'InOutItemName', width:230, hidden:itemType},
- { title: '账户名称', field: 'AccountName', width:230, hidden:moneyType},
- { title: '金额',field: 'EachAmount',width:70},
- { title: '备注',field: 'Remark',width:150}
- ]],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/accountItem/getDetailList',
- data: {
- headerId: accountHeadID
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var EachAmount = TotalPrice;
- var array = [];
- array.push({
- "EachAmount": EachAmount
- });
- data.footer = array;
- $("#accountDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showAccountHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除财务信息
-function deleteAccountHead(accountHeadID, thisOrganId, totalPrice){
- $.messager.confirm('删除确认','确定要删除此财务信息吗?',function(r)
- {
- if (r)
- {
- $.ajax({
- type:"post",
- url: "/accountHead/batchDeleteAccountHeadByIds",
- dataType: "json",
- data:{
- ids: accountHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=accountHeadID;
- jsondata.deleteType='2';
- var type='single';
- batDeleteAccountHeadForceConfirm(res,"/accountHead/batchDeleteAccountHeadByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
-
- }
- });
-}
-
-//批量删除财务信息
-function batDeleteAccountHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条财务信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1)
- {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
-
- //批量删除
- $.ajax({
- type:"post",
- url: "/accountHead/batchDeleteAccountHeadByIds",
- dataType: "json",
- async : false,
- data: ({
- ids : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=ids;
- jsondata.deleteType='2';
- var type='batch';
- batDeleteAccountHeadForceConfirm(res,"/accountHead/batchDeleteAccountHeadByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- }
-}
-/**
- * 确认强制删除
- * */
-function batDeleteAccountHeadForceConfirm(res,url,jsondata) {
- $.messager.confirm('删除确认', res.msg, function (r) {
- if (r) {
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: (jsondata),
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- if(type=='batch'){
- $(":checkbox").attr("checked", false);
- }
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-
-//增加
-function addAccountHead(){
- $('#accountHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#BillTime").val(thisDateTime);
- var thisNumber = getNowFormatDateNum(); //根据时间生成编号
- $("#BillNo").val(amountNum + thisNumber).focus();
- var addTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgAccountHead = "";
- accountHeadID = 0;
- initTableData_account("add"); //明细列表
- reject(); //撤销下、刷新材料列表
- url = '/accountHead/addAccountHeadAndDetail';
-
-}
-
-//编辑信息
-function editAccountHead(index){
- // var accountHeadInfo = accountHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#BillNo").val(rowsdata.billno);
- $("#BillTime").val(rowsdata.billtime);
- $("#Remark").val(rowsdata.remark);
- $("#AccountId").val(rowsdata.accountid);
- // $('#OrganId').combobox('setValue', rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#ChangeAmount").val(rowsdata.changeamount);
- var TotalPrice = rowsdata.totalprice;
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于收预付款
- var editTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- accountHeadID = rowsdata.id;
-
- initTableData_account("edit",TotalPrice); //明细列表
- reject(); //撤销下、刷新列表
- url = '/accountHead/updateAccountHeadAndDetail?id=' + rowsdata.id;
-}
-
-//查看信息
-function showAccountHead(index){
- // var accountHeadInfo = accountHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#BillNoShow").text(rowsdata.billno);
- $("#BillTimeShow").text(rowsdata.billtime);
- $("#RemarkShow").text(rowsdata.remark);
- $("#AccountIdShow").text(rowsdata.accountname);
- $('#OrganIdShow').text(rowsdata.organname);
- $("#HandsPersonIdShow").text(rowsdata.handspersonname);
- $("#ChangeAmountShow").text(rowsdata.rowsdata==undefined?'0':rowsdata.rowsdata);
- var TotalPrice = rowsdata.totalprice;
- var showTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlgShow').dialog('open').dialog('setTitle','
查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- accountHeadID = rowsdata.id;
- initTableData_account_show(TotalPrice); //明细列表-查看状态
-}
-
-//绑定操作事件
-function bindEvent(){
- //搜索处理
- $("#searchBtn").unbind().bind({
- click:function()
- {
- showAccountHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh', {
- pageNumber:1,
- pageSize:initPageSize
- });
- }
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- $("#searchBillNo").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //保存信息
- $("#saveAccountHead").off("click").on("click", function () {
- if(!$('#accountHeadFM').form('validate')){
- return;
- } else {
- if (!$('#HandsPersonId').val()) {
- $.messager.alert('提示', '请选择经手人!', 'warning');
- return;
- }
- if (!$('#AccountId').val()) {
- $.messager.alert('提示', '请选择付款账户!', 'warning');
- return;
- }
- var OrganId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val());
- var TotalPrice = $("#accountHeadFM .datagrid-footer [field='EachAmount'] div").text();
- //支出为负数
- ChangeAmount = 0 - ChangeAmount;
- //支出和付款为负数
- TotalPrice = 0 - TotalPrice;
- saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId);
- }
- });
-
- //打印单据
- $("#printAccountHeadShow").off("click").on("click",function(){
- var tableString = $("#accountHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event)
- {
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="BillNo"||obj.id=="BillTime"))
- {
- $("#saveAccountHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchBillNo"))
- {
- $("#searchBtn").click();
- }
- });
-}
-
-function showAccountHeadDetails(pageNo,pageSize){
- $.ajax({
- type:"get",
- url: "/accountHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- billNo: $.trim($("#searchBillNo").val()),
- beginTime: $("#searchBeginTime").val(),
- endTime: $("#searchEndTime").val()
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#accountHeadFM .datagrid-body");
- var footer =$("#accountHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
-
- //修改金额,自动计算单价和合计
- body.find("[field='EachAmount']").find(input).off("keyup").on("keyup",function(){
- var TotalPrice = 0;
- var EachAmount =$(this).val()-0; //金额
- body.find("[field='EachAmount']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + EachAmount;
- footer.find("[field='EachAmount']").find("div").text((TotalPrice).toFixed(2));
- });
- },500);
-}
-
-//结束编辑
-function endEditing() {
- var edField = "";
- if(!itemType){
- edField = "InOutItemId";
- edName = "InOutItemName";
- }
- else {
- edField = "AccountId";
- edName = "AccountName";
- }
- if (editIndex == undefined) { return true }
- if ($('#accountData').datagrid('validateRow', editIndex)) {
- var ed = $('#accountData').datagrid('getEditor', {index: editIndex, field: edField});
- var textName =null;
- if($(ed.target)){
- textName = $(ed.target).combobox('getText');
- }
- $('#accountData').datagrid('getRows')[editIndex][edName] = textName;
- $('#accountData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#accountData').datagrid('selectRow', index)
- .datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#accountData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append() {
- if (endEditing()) {
- $('#accountData').datagrid('appendRow', {});
- editIndex = $('#accountData').datagrid('getRows').length - 1;
- $('#accountData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function removeit() {
- if (editIndex == undefined) { return }
- $('#accountData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#accountData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData() {
- var row = $('#accountData').datagrid('getRows');
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if(!itemType){
- if (row[i].InOutItemId == "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- else{
- if (row[i].AccountId == "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-function saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId) {
- if (editIndex != undefined) {
- $('#accountData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- if (!CheckData())
- return false;
- var inserted = $("#accountData").datagrid('getChanges', "inserted");
- var deleted = $("#accountData").datagrid('getChanges', "deleted");
- var updated = $("#accountData").datagrid('getChanges', "updated");
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: {
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- info : JSON.stringify({
- Type: listType,
- BillNo: $.trim($("#BillNo").val()),
- BillTime: $.trim($("#BillTime").val()),
- AccountId: $.trim($("#AccountId").val()),
- ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
- TotalPrice: TotalPrice, //合计
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Remark: $.trim($("#Remark").val())
- }),
- listType: listType
- },
- success: function (tipInfo)
- {
- if (tipInfo) {
- $.messager.alert('提示','保存成功!','info');
- $('#accountHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showAccountHeadDetails(opts.pageNumber, opts.pageSize);
- }
- else{
-
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- error: function (XmlHttpRequest, textStatus, errorThrown)
- {
- $.messager.alert('提示',XmlHttpRequest.responseText,'error');
- }
- });
-}
\ No newline at end of file
diff --git a/erp_web/js/pages/financial/item_in.js b/erp_web/js/pages/financial/item_in.js
deleted file mode 100644
index 04abb162..00000000
--- a/erp_web/js/pages/financial/item_in.js
+++ /dev/null
@@ -1,872 +0,0 @@
-//初始化界面
-var listTitle ="收入单列表"
-var listType = "收入";
-var itemType = false; //显示当前列
-var moneyType = true; //隐藏当前列
-var payTypeTitle = "收入项目";
-var inOrOut = "in";
-var organUrl = "/supplier/findBySelect_cus"; //客户接口
-var amountNum = "SR";
-$(function(){
- initSystemData_person(); //经手人数据
- initSelectInfo_person(); //经手人信息
- initSystemData_account(); //账户数据
- initSelectInfo_account(); //账户信息
- initSupplier(); //供应商
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
- $("#searchBtn").click();
-});
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null)
- {
- options = "";
- for(var i = 0 ;i < accountList.length; i++)
- {
- var account = accountList[i];
- options += '';
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//初始化单位信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- formatter: function(row){
- var opts = $(this).combobox('options');
- if(row[opts.textField]!=="非会员") {
- return row[opts.textField];
- }
- }
- });
-}
-
-//获取财务员
-function initSystemData_person(){
- var type = "财务员";
- $.ajax({
- type:"get",
- url: "/person/getPersonByType",
- data: {
- type: type
- },
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- personList = res.data.personList;
- }
- }
- });
-}
-//获取财务员
-function initSelectInfo_person(){
- var options = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="财务员")
- {
- options += '';
- }
- }
- $("#HandsPersonId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#accountHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- var organNameTitle = "往来单位";
- var organNameHidden = false;
- $('#tableData').datagrid({
- //width:700,
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //fitColumns:true,
- //单击行是否选中
- //checkOnSelect : false,
- pagination: true,
- //交替出现背景
- striped : true,
- //loadFilter: pagerFilter,
- pageSize: 5,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:90,formatter:function(value, rec,index) {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/7 10:48
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js
- */
- var str = '';
- var orgId = rec.organid ? rec.organid : 0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { field: 'organid',width:5, hidden:true},
- { title: organNameTitle,field: 'organname',width:140,hidden:organNameHidden},
- { title: '单据编号',field: 'billno',width:140},
- { title: '经手人',field: 'handspersonname',width:80},
- { title: '单据时间 ',field: 'billtime',width:140},
- { title: '合计',field: 'totalprice',width:80},
- { title: '备注',field: 'remark',width:100}
- ]],
- toolbar:[
- {
- id:'addAccountHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addAccountHead();
- }
- },
- {
- id:'deleteAccountHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteAccountHead();
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化表格数据-明细列表-编辑状态
-function initTableData_account(type,TotalPrice){
- $('#accountData').datagrid({
- height:280,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: payTypeTitle,field: 'InOutItemId',width:230,hidden:itemType,
- formatter:function(value,row,index){
- return row.InOutItemName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'InOutItemName',
- method:'get',
- url: "/inOutItem/findBySelect?type=" + inOrOut
- }
- }
- },
- { title: '账户名称',field: 'AccountId',width:230,hidden:moneyType,
- formatter:function(value,row,index){
- return row.AccountName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'AccountName',
- method:'get',
- url: "/account/findBySelect"
- }
- }
- },
- { title: '金额',field: 'EachAmount',editor:'validatebox',width:70},
- { title: '备注',field: 'Remark',editor:'validatebox',width:150}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- removeit(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/accountItem/getDetailList',
- data: {
- headerId: accountHeadID
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var EachAmount = 0;
- if(type === "edit") {
- EachAmount = TotalPrice;
- }
- var array = [];
- array.push({
- "EachAmount": EachAmount
- });
- data.footer = array;
- $("#accountData").datagrid('loadData',data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-
-//初始化表格数据-明细列表-查看状态
-function initTableData_account_show(TotalPrice){
- $('#accountDataShow').datagrid({
- height:280,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { title: payTypeTitle, field: 'InOutItemName', width:230, hidden:itemType},
- { title: '账户名称', field: 'AccountName', width:230, hidden:moneyType},
- { title: '金额',field: 'EachAmount',width:70},
- { title: '备注',field: 'Remark',width:150}
- ]],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/accountItem/getDetailList',
- data: {
- headerId: accountHeadID
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var EachAmount = TotalPrice;
- var array = [];
- array.push({
- "EachAmount": EachAmount
- });
- data.footer = array;
- $("#accountDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showAccountHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除财务信息
-function deleteAccountHead(accountHeadID, thisOrganId, totalPrice){
- $.messager.confirm('删除确认','确定要删除此财务信息吗?',function(r)
- {
- if (r)
- {
- $.ajax({
- type:"post",
- url: "/accountHead/batchDeleteAccountHeadByIds",
- dataType: "json",
- data:{
- ids: accountHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=accountHeadID;
- jsondata.deleteType='2';
- var type='single';
- batDeleteAccountHeadForceConfirm(res,"/accountHead/batchDeleteAccountHeadByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
-
- }
- });
-}
-
-//批量删除财务信息
-function batDeleteAccountHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条财务信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1)
- {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
-
- //批量删除
- $.ajax({
- type:"post",
- url: "/accountHead/batchDeleteAccountHeadByIds",
- dataType: "json",
- async : false,
- data: ({
- ids : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=ids;
- jsondata.deleteType='2';
- var type='batch';
- batDeleteAccountHeadForceConfirm(res,"/accountHead/batchDeleteAccountHeadByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- }
-}
-/**
- * 确认强制删除
- * */
-function batDeleteAccountHeadForceConfirm(res,url,jsondata) {
- $.messager.confirm('删除确认', res.msg, function (r) {
- if (r) {
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: (jsondata),
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- if(type=='batch'){
- $(":checkbox").attr("checked", false);
- }
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-
-//增加
-function addAccountHead(){
- $('#accountHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#BillTime").val(thisDateTime);
- var thisNumber = getNowFormatDateNum(); //根据时间生成编号
- $("#BillNo").val(amountNum + thisNumber).focus();
- var addTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgAccountHead = "";
- accountHeadID = 0;
- initTableData_account("add"); //明细列表
- reject(); //撤销下、刷新材料列表
- url = '/accountHead/addAccountHeadAndDetail';
-
-}
-
-//编辑信息
-function editAccountHead(index){
- // var accountHeadInfo = accountHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#BillNo").val(rowsdata.billno);
- $("#BillTime").val(rowsdata.billtime);
- $("#Remark").val(rowsdata.remark);
- $("#AccountId").val(rowsdata.accountid);
- $('#OrganId').combobox('setValue', rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#ChangeAmount").val(rowsdata.changeamount);
- var TotalPrice = rowsdata.totalprice;
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于收预付款
- var editTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- accountHeadID = rowsdata.id;
-
- initTableData_account("edit",TotalPrice); //明细列表
- reject(); //撤销下、刷新列表
- url = '/accountHead/updateAccountHeadAndDetail?id=' + rowsdata.id;
-}
-
-//查看信息
-function showAccountHead(index){
- // var accountHeadInfo = accountHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#BillNoShow").text(rowsdata.billno);
- $("#BillTimeShow").text(rowsdata.billtime);
- $("#RemarkShow").text(rowsdata.remark);
- $("#AccountIdShow").text(rowsdata.accountname);
- $('#OrganIdShow').text(rowsdata.organname);
- $("#HandsPersonIdShow").text(rowsdata.handspersonname);
- $("#ChangeAmountShow").text(rowsdata.rowsdata==undefined?'0':rowsdata.rowsdata);
- var TotalPrice = rowsdata.totalprice;
- var showTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlgShow').dialog('open').dialog('setTitle','
查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- accountHeadID = rowsdata.id;
- initTableData_account_show(TotalPrice); //明细列表-查看状态
-}
-
-//绑定操作事件
-function bindEvent(){
- //搜索处理
- $("#searchBtn").unbind().bind({
- click:function()
- {
- showAccountHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh', {
- pageNumber:1,
- pageSize:initPageSize
- });
- }
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- $("#searchBillNo").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //保存信息
- $("#saveAccountHead").off("click").on("click", function () {
- if(!$('#accountHeadFM').form('validate')){
- return;
- } else {
- if (!$('#AccountId').val()) {
- $.messager.alert('提示', '请选择收款账户!', 'warning');
- return;
- }
- if (!$('#OrganId').combobox('getValue')) {
- $.messager.alert('提示', '请选择往来单位!', 'warning');
- return;
- }
- if (!$('#HandsPersonId').val()) {
- $.messager.alert('提示', '请选择经手人!', 'warning');
- return;
- }
- var ChangeAmount = $.trim($("#ChangeAmount").val());
- var TotalPrice = $("#accountHeadFM .datagrid-footer [field='EachAmount'] div").text();
- var OrganId = $('#OrganId').combobox('getValue');
-
- saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId);
- }
- });
-
- //打印单据
- $("#printAccountHeadShow").off("click").on("click",function(){
- var tableString = $("#accountHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event)
- {
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="BillNo"||obj.id=="BillTime"))
- {
- $("#saveAccountHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchBillNo"))
- {
- $("#searchBtn").click();
- }
- });
-}
-
-function showAccountHeadDetails(pageNo,pageSize){
- $.ajax({
- type:"get",
- url: "/accountHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- billNo: $.trim($("#searchBillNo").val()),
- beginTime: $("#searchBeginTime").val(),
- endTime: $("#searchEndTime").val()
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#accountHeadFM .datagrid-body");
- var footer =$("#accountHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
-
- //修改金额,自动计算单价和合计
- body.find("[field='EachAmount']").find(input).off("keyup").on("keyup",function(){
- var TotalPrice = 0;
- var EachAmount =$(this).val()-0; //金额
- body.find("[field='EachAmount']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + EachAmount;
- footer.find("[field='EachAmount']").find("div").text((TotalPrice).toFixed(2));
- });
- },500);
-}
-
-//结束编辑
-function endEditing() {
- var edField = "";
- if(!itemType){
- edField = "InOutItemId";
- edName = "InOutItemName";
- }
- else {
- edField = "AccountId";
- edName = "AccountName";
- }
- if (editIndex == undefined) { return true }
- if ($('#accountData').datagrid('validateRow', editIndex)) {
- var ed = $('#accountData').datagrid('getEditor', {index: editIndex, field: edField});
- var textName =null;
- if($(ed.target)){
- textName = $(ed.target).combobox('getText');
- }
- $('#accountData').datagrid('getRows')[editIndex][edName] = textName;
- $('#accountData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#accountData').datagrid('selectRow', index)
- .datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#accountData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append() {
- if (endEditing()) {
- $('#accountData').datagrid('appendRow', {});
- editIndex = $('#accountData').datagrid('getRows').length - 1;
- $('#accountData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function removeit() {
- if (editIndex == undefined) { return }
- $('#accountData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#accountData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData() {
- var row = $('#accountData').datagrid('getRows');
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if(!itemType){
- if (row[i].InOutItemId == "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- else{
- if (row[i].AccountId == "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-function saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId) {
- if (editIndex != undefined) {
- $('#accountData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- if (!CheckData())
- return false;
- var inserted = $("#accountData").datagrid('getChanges', "inserted");
- var deleted = $("#accountData").datagrid('getChanges', "deleted");
- var updated = $("#accountData").datagrid('getChanges', "updated");
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: {
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- info : JSON.stringify({
- Type: listType,
- BillNo: $.trim($("#BillNo").val()),
- BillTime: $.trim($("#BillTime").val()),
- AccountId: $.trim($("#AccountId").val()),
- ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
- TotalPrice: TotalPrice, //合计
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Remark: $.trim($("#Remark").val())
- }),
- listType: listType
- },
- success: function (tipInfo)
- {
- if (tipInfo) {
- $.messager.alert('提示','保存成功!','info');
- $('#accountHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showAccountHeadDetails(opts.pageNumber, opts.pageSize);
- }
- else{
-
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- error: function (XmlHttpRequest, textStatus, errorThrown)
- {
- $.messager.alert('提示',XmlHttpRequest.responseText,'error');
- }
- });
-}
\ No newline at end of file
diff --git a/erp_web/js/pages/financial/item_out.js b/erp_web/js/pages/financial/item_out.js
deleted file mode 100644
index 5ba534dd..00000000
--- a/erp_web/js/pages/financial/item_out.js
+++ /dev/null
@@ -1,878 +0,0 @@
-//初始化界面
-var listTitle ="支出单列表";
-var listType = "支出";
-var itemType = false; //显示当前列
-var moneyType = true; //隐藏当前列
-var payTypeTitle = "支出项目";
-var inOrOut = "out";
-var organUrl = "/supplier/findBySelect_sup"; //供应商接口
-var amountNum = "ZC";
-$(function(){
- initSystemData_person(); //经手人数据
- initSelectInfo_person(); //经手人信息
- initSystemData_account(); //账户数据
- initSelectInfo_account(); //账户信息
- initSupplier(); //供应商
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
- $("#searchBtn").click();
-});
-
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null)
- {
- options = "";
- for(var i = 0 ;i < accountList.length; i++)
- {
- var account = accountList[i];
- options += '';
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//初始化单位信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- formatter: function(row){
- var opts = $(this).combobox('options');
- if(row[opts.textField]!=="非会员") {
- return row[opts.textField];
- }
- }
- });
-}
-
-//获取财务员
-function initSystemData_person(){
- var type = "财务员";
- $.ajax({
- type:"get",
- url: "/person/getPersonByType",
- data: {
- type: type
- },
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- personList = res.data.personList;
- }
- }
- });
-}
-//获取财务员
-function initSelectInfo_person(){
- var options = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="财务员")
- {
- options += '';
- }
- }
- $("#HandsPersonId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#accountHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- var organNameTitle = "往来单位";
- var organNameHidden = false;
- $('#tableData').datagrid({
- //width:700,
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //fitColumns:true,
- //单击行是否选中
- //checkOnSelect : false,
- pagination: true,
- //交替出现背景
- striped : true,
- //loadFilter: pagerFilter,
- pageSize: 5,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:90,formatter:function(value, rec,index) {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/7 10:48
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js
- */
- var str = '';
- var orgId = rec.organid ? rec.organid : 0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { field: 'organid',width:5, hidden:true},
- { title: organNameTitle,field: 'organname',width:140,hidden:organNameHidden},
- { title: '单据编号',field: 'billno',width:140},
- { title: '经手人',field: 'handspersonname',width:80},
- { title: '单据时间 ',field: 'billtime',width:140},
- { title: '合计',field: 'totalprice',width:80},
- { title: '备注',field: 'remark',width:100}
- ]],
- toolbar:[
- {
- id:'addAccountHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addAccountHead();
- }
- },
- {
- id:'deleteAccountHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteAccountHead();
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化表格数据-明细列表-编辑状态
-function initTableData_account(type,TotalPrice){
- $('#accountData').datagrid({
- height:280,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: payTypeTitle,field: 'InOutItemId',width:230,hidden:itemType,
- formatter:function(value,row,index){
- return row.InOutItemName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'InOutItemName',
- method:'get',
- url: "/inOutItem/findBySelect?type=" + inOrOut
- }
- }
- },
- { title: '账户名称',field: 'AccountId',width:230,hidden:moneyType,
- formatter:function(value,row,index){
- return row.AccountName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'AccountName',
- method:'get',
- url: "/account/findBySelect"
- }
- }
- },
- { title: '金额',field: 'EachAmount',editor:'validatebox',width:70},
- { title: '备注',field: 'Remark',editor:'validatebox',width:150}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- removeit(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/accountItem/getDetailList',
- data: {
- headerId: accountHeadID
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var EachAmount = 0;
- if(type === "edit") {
- EachAmount = TotalPrice;
- }
- var array = [];
- array.push({
- "EachAmount": EachAmount
- });
- data.footer = array;
- $("#accountData").datagrid('loadData',data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-
-//初始化表格数据-明细列表-查看状态
-function initTableData_account_show(TotalPrice){
- $('#accountDataShow').datagrid({
- height:280,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { title: payTypeTitle, field: 'InOutItemName', width:230, hidden:itemType},
- { title: '账户名称', field: 'AccountName', width:230, hidden:moneyType},
- { title: '金额',field: 'EachAmount',width:70},
- { title: '备注',field: 'Remark',width:150}
- ]],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/accountItem/getDetailList',
- data: {
- headerId: accountHeadID
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var EachAmount = TotalPrice;
- var array = [];
- array.push({
- "EachAmount": EachAmount
- });
- data.footer = array;
- $("#accountDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showAccountHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除财务信息
-function deleteAccountHead(accountHeadID, thisOrganId, totalPrice){
- $.messager.confirm('删除确认','确定要删除此财务信息吗?',function(r)
- {
- if (r)
- {
- $.ajax({
- type:"post",
- url: "/accountHead/batchDeleteAccountHeadByIds",
- dataType: "json",
- data:{
- ids: accountHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=accountHeadID;
- jsondata.deleteType='2';
- var type='single';
- batDeleteAccountHeadForceConfirm(res,"/accountHead/batchDeleteAccountHeadByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
-
- }
- });
-}
-
-//批量删除财务信息
-function batDeleteAccountHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条财务信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1)
- {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
-
- //批量删除
- $.ajax({
- type:"post",
- url: "/accountHead/batchDeleteAccountHeadByIds",
- dataType: "json",
- async : false,
- data: ({
- ids : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=ids;
- jsondata.deleteType='2';
- var type='batch';
- batDeleteAccountHeadForceConfirm(res,"/accountHead/batchDeleteAccountHeadByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- }
-}
-/**
- * 确认强制删除
- * */
-function batDeleteAccountHeadForceConfirm(res,url,jsondata) {
- $.messager.confirm('删除确认', res.msg, function (r) {
- if (r) {
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: (jsondata),
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- if(type=='batch'){
- $(":checkbox").attr("checked", false);
- }
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-
-//增加
-function addAccountHead(){
- $('#accountHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#BillTime").val(thisDateTime);
- var thisNumber = getNowFormatDateNum(); //根据时间生成编号
- $("#BillNo").val(amountNum + thisNumber).focus();
- var addTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgAccountHead = "";
- accountHeadID = 0;
- initTableData_account("add"); //明细列表
- reject(); //撤销下、刷新材料列表
- url = '/accountHead/addAccountHeadAndDetail';
-
-}
-
-//编辑信息
-function editAccountHead(index){
- // var accountHeadInfo = accountHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#BillNo").val(rowsdata.billno);
- $("#BillTime").val(rowsdata.billtime);
- $("#Remark").val(rowsdata.remark);
- $("#AccountId").val(rowsdata.accountid);
- $('#OrganId').combobox('setValue', rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#ChangeAmount").val(rowsdata.changeamount);
- var TotalPrice = rowsdata.totalprice;
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于收预付款
- var editTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- accountHeadID = rowsdata.id;
-
- initTableData_account("edit",TotalPrice); //明细列表
- reject(); //撤销下、刷新列表
- url = '/accountHead/updateAccountHeadAndDetail?id=' + rowsdata.id;
-}
-
-//查看信息
-function showAccountHead(index){
- // var accountHeadInfo = accountHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#BillNoShow").text(rowsdata.billno);
- $("#BillTimeShow").text(rowsdata.billtime);
- $("#RemarkShow").text(rowsdata.remark);
- $("#AccountIdShow").text(rowsdata.accountname);
- $('#OrganIdShow').text(rowsdata.organname);
- $("#HandsPersonIdShow").text(rowsdata.handspersonname);
- $("#ChangeAmountShow").text(rowsdata.rowsdata==undefined?'0':rowsdata.rowsdata);
- var TotalPrice = rowsdata.totalprice;
- var showTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlgShow').dialog('open').dialog('setTitle','
查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- accountHeadID = rowsdata.id;
- initTableData_account_show(TotalPrice); //明细列表-查看状态
-}
-
-//绑定操作事件
-function bindEvent(){
- //搜索处理
- $("#searchBtn").unbind().bind({
- click:function()
- {
- showAccountHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh', {
- pageNumber:1,
- pageSize:initPageSize
- });
- }
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- $("#searchBillNo").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //保存信息
- $("#saveAccountHead").off("click").on("click", function () {
- if(!$('#accountHeadFM').form('validate')){
- return;
- } else {
- if (!$('#AccountId').val()) {
- $.messager.alert('提示', '请选择付款账户!', 'warning');
- return;
- }
- if (!$('#OrganId').combobox('getValue')) {
- $.messager.alert('提示', '请选择往来单位!', 'warning');
- return;
- }
- if (!$('#HandsPersonId').val()) {
- $.messager.alert('提示', '请选择经手人!', 'warning');
- return;
- }
- var OrganId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val());
- var TotalPrice = $("#accountHeadFM .datagrid-footer [field='EachAmount'] div").text();
- OrganId = $('#OrganId').combobox('getValue');
- //支出为负数
- ChangeAmount = 0 - ChangeAmount;
- //支出和付款为负数
- TotalPrice = 0 - TotalPrice;
-
- saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId);
- }
- });
-
- //打印单据
- $("#printAccountHeadShow").off("click").on("click",function(){
- var tableString = $("#accountHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event)
- {
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="BillNo"||obj.id=="BillTime"))
- {
- $("#saveAccountHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchBillNo"))
- {
- $("#searchBtn").click();
- }
- });
-}
-
-function showAccountHeadDetails(pageNo,pageSize){
- $.ajax({
- type:"get",
- url: "/accountHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- billNo: $.trim($("#searchBillNo").val()),
- beginTime: $("#searchBeginTime").val(),
- endTime: $("#searchEndTime").val()
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#accountHeadFM .datagrid-body");
- var footer =$("#accountHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
-
- //修改金额,自动计算单价和合计
- body.find("[field='EachAmount']").find(input).off("keyup").on("keyup",function(){
- var TotalPrice = 0;
- var EachAmount =$(this).val()-0; //金额
- body.find("[field='EachAmount']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + EachAmount;
- footer.find("[field='EachAmount']").find("div").text((TotalPrice).toFixed(2));
- });
- },500);
-}
-
-//结束编辑
-function endEditing() {
- var edField = "";
- if(!itemType){
- edField = "InOutItemId";
- edName = "InOutItemName";
- }
- else {
- edField = "AccountId";
- edName = "AccountName";
- }
- if (editIndex == undefined) { return true }
- if ($('#accountData').datagrid('validateRow', editIndex)) {
- var ed = $('#accountData').datagrid('getEditor', {index: editIndex, field: edField});
- var textName =null;
- if($(ed.target)){
- textName = $(ed.target).combobox('getText');
- }
- $('#accountData').datagrid('getRows')[editIndex][edName] = textName;
- $('#accountData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#accountData').datagrid('selectRow', index)
- .datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#accountData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append() {
- if (endEditing()) {
- $('#accountData').datagrid('appendRow', {});
- editIndex = $('#accountData').datagrid('getRows').length - 1;
- $('#accountData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function removeit() {
- if (editIndex == undefined) { return }
- $('#accountData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#accountData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData() {
- var row = $('#accountData').datagrid('getRows');
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if(!itemType){
- if (row[i].InOutItemId == "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- else{
- if (row[i].AccountId == "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-function saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId) {
- if (editIndex != undefined) {
- $('#accountData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- if (!CheckData())
- return false;
- var inserted = $("#accountData").datagrid('getChanges', "inserted");
- var deleted = $("#accountData").datagrid('getChanges', "deleted");
- var updated = $("#accountData").datagrid('getChanges', "updated");
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: {
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- info : JSON.stringify({
- Type: listType,
- BillNo: $.trim($("#BillNo").val()),
- BillTime: $.trim($("#BillTime").val()),
- AccountId: $.trim($("#AccountId").val()),
- ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
- TotalPrice: TotalPrice, //合计
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Remark: $.trim($("#Remark").val())
- }),
- listType: listType
- },
- success: function (tipInfo)
- {
- if (tipInfo) {
- $.messager.alert('提示','保存成功!','info');
- $('#accountHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showAccountHeadDetails(opts.pageNumber, opts.pageSize);
- }
- else{
-
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- error: function (XmlHttpRequest, textStatus, errorThrown)
- {
- $.messager.alert('提示',XmlHttpRequest.responseText,'error');
- }
- });
-}
\ No newline at end of file
diff --git a/erp_web/js/pages/financial/money_in.js b/erp_web/js/pages/financial/money_in.js
deleted file mode 100644
index fa1f64b6..00000000
--- a/erp_web/js/pages/financial/money_in.js
+++ /dev/null
@@ -1,868 +0,0 @@
-//初始化界面
-var listTitle ="收款单列表";
-var listType = "收款";
-var itemType = true; //隐藏当前列
-var moneyType = false; //显示当前列
-var payTypeTitle = "无标题";
-var inOrOut = "";
-var organUrl = "/supplier/findBySelect_cus"; //客户接口
-var amountNum = "SK";
-$(function(){
- initSystemData_person(); //经手人数据
- initSelectInfo_person(); //经手人信息
- initSystemData_account(); //账户数据
- initSelectInfo_account(); //账户信息
- initSupplier(); //供应商
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
- $("#searchBtn").click();
-});
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null)
- {
- options = "";
- for(var i = 0 ;i < accountList.length; i++)
- {
- var account = accountList[i];
- options += '';
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//初始化单位信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- formatter: function(row){
- var opts = $(this).combobox('options');
- if(row[opts.textField]!=="非会员") {
- return row[opts.textField];
- }
- }
- });
-}
-
-//获取财务员
-function initSystemData_person(){
- var type = "财务员";
- $.ajax({
- type:"get",
- url: "/person/getPersonByType",
- data: {
- type: type
- },
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- personList = res.data.personList;
- }
- }
- });
-}
-//获取财务员
-function initSelectInfo_person(){
- var options = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="财务员")
- {
- options += '';
- }
- }
- $("#HandsPersonId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#accountHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- var organNameTitle ="付款单位";
- var organNameHidden = false;
- $('#tableData').datagrid({
- //width:700,
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //fitColumns:true,
- //单击行是否选中
- //checkOnSelect : false,
- pagination: true,
- //交替出现背景
- striped : true,
- //loadFilter: pagerFilter,
- pageSize: 5,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:90,formatter:function(value, rec,index) {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/7 10:48
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js
- */
- var str = '';
- var orgId = rec.organid ? rec.organid : 0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { field: 'organid',width:5, hidden:true},
- { title: organNameTitle,field: 'organname',width:140,hidden:organNameHidden},
- { title: '单据编号',field: 'billno',width:140},
- { title: '经手人',field: 'handspersonname',width:80},
- { title: '单据时间 ',field: 'billtime',width:140},
- { title: '合计',field: 'totalprice',width:80},
- { title: '备注',field: 'remark',width:100}
- ]],
- toolbar:[
- {
- id:'addAccountHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addAccountHead();
- }
- },
- {
- id:'deleteAccountHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteAccountHead();
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化表格数据-明细列表-编辑状态
-function initTableData_account(type,TotalPrice){
- $('#accountData').datagrid({
- height:280,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: payTypeTitle,field: 'InOutItemId',width:230,hidden:itemType,
- formatter:function(value,row,index){
- return row.InOutItemName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'InOutItemName',
- method:'get',
- url: "/inOutItem/findBySelect?type=" + inOrOut
- }
- }
- },
- { title: '账户名称',field: 'AccountId',width:230,hidden:moneyType,
- formatter:function(value,row,index){
- return row.AccountName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'AccountName',
- method:'get',
- url: "/account/findBySelect"
- }
- }
- },
- { title: '金额',field: 'EachAmount',editor:'validatebox',width:70},
- { title: '备注',field: 'Remark',editor:'validatebox',width:150}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- removeit(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/accountItem/getDetailList',
- data: {
- headerId: accountHeadID
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var EachAmount = 0;
- if(type === "edit") {
- EachAmount = TotalPrice;
- }
- var array = [];
- array.push({
- "EachAmount": EachAmount
- });
- data.footer = array;
- $("#accountData").datagrid('loadData',data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-
-//初始化表格数据-明细列表-查看状态
-function initTableData_account_show(TotalPrice){
- $('#accountDataShow').datagrid({
- height:280,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { title: payTypeTitle, field: 'InOutItemName', width:230, hidden:itemType},
- { title: '账户名称', field: 'AccountName', width:230, hidden:moneyType},
- { title: '金额',field: 'EachAmount',width:70},
- { title: '备注',field: 'Remark',width:150}
- ]],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/accountItem/getDetailList',
- data: {
- headerId: accountHeadID
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var EachAmount = TotalPrice;
- var array = [];
- array.push({
- "EachAmount": EachAmount
- });
- data.footer = array;
- $("#accountDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showAccountHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除财务信息
-function deleteAccountHead(accountHeadID, thisOrganId, totalPrice){
- $.messager.confirm('删除确认','确定要删除此财务信息吗?',function(r)
- {
- if (r)
- {
- $.ajax({
- type:"post",
- url: "/accountHead/batchDeleteAccountHeadByIds",
- dataType: "json",
- data:{
- ids: accountHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=accountHeadID;
- jsondata.deleteType='2';
- var type='single';
- batDeleteAccountHeadForceConfirm(res,"/accountHead/batchDeleteAccountHeadByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
-
- }
- });
-}
-
-//批量删除财务信息
-function batDeleteAccountHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条财务信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1)
- {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
-
- //批量删除
- $.ajax({
- type:"post",
- url: "/accountHead/batchDeleteAccountHeadByIds",
- dataType: "json",
- async : false,
- data: ({
- ids : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=ids;
- jsondata.deleteType='2';
- var type='batch';
- batDeleteAccountHeadForceConfirm(res,"/accountHead/batchDeleteAccountHeadByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- }
-}
-/**
- * 确认强制删除
- * */
-function batDeleteAccountHeadForceConfirm(res,url,jsondata) {
- $.messager.confirm('删除确认', res.msg, function (r) {
- if (r) {
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: (jsondata),
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- if(type=='batch'){
- $(":checkbox").attr("checked", false);
- }
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-
-//增加
-function addAccountHead(){
- $('#accountHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#BillTime").val(thisDateTime);
- var thisNumber = getNowFormatDateNum(); //根据时间生成编号
- $("#BillNo").val(amountNum + thisNumber).focus();
- var addTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgAccountHead = "";
- accountHeadID = 0;
- initTableData_account("add"); //明细列表
- reject(); //撤销下、刷新材料列表
- url = '/accountHead/addAccountHeadAndDetail';
-
-}
-
-//编辑信息
-function editAccountHead(index){
- // var accountHeadInfo = accountHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#BillNo").val(rowsdata.billno);
- $("#BillTime").val(rowsdata.billtime);
- $("#Remark").val(rowsdata.remark);
- $("#AccountId").val(rowsdata.accountid);
- $('#OrganId').combobox('setValue', rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#ChangeAmount").val(rowsdata.changeamount);
- var TotalPrice = rowsdata.totalprice;
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于收预付款
- var editTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- accountHeadID = rowsdata.id;
-
- initTableData_account("edit",TotalPrice); //明细列表
- reject(); //撤销下、刷新列表
- url = '/accountHead/updateAccountHeadAndDetail?id=' + rowsdata.id;
-}
-
-//查看信息
-function showAccountHead(index){
- // var accountHeadInfo = accountHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#BillNoShow").text(rowsdata.billno);
- $("#BillTimeShow").text(rowsdata.billtime);
- $("#RemarkShow").text(rowsdata.remark);
- $("#AccountIdShow").text(rowsdata.accountname);
- $('#OrganIdShow').text(rowsdata.organname);
- $("#HandsPersonIdShow").text(rowsdata.handspersonname);
- $("#ChangeAmountShow").text(rowsdata.rowsdata==undefined?'0':rowsdata.rowsdata);
- var TotalPrice = rowsdata.totalprice;
- var showTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlgShow').dialog('open').dialog('setTitle','
查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- accountHeadID = rowsdata.id;
- initTableData_account_show(TotalPrice); //明细列表-查看状态
-}
-
-//绑定操作事件
-function bindEvent(){
- //搜索处理
- $("#searchBtn").unbind().bind({
- click:function()
- {
- showAccountHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh', {
- pageNumber:1,
- pageSize:initPageSize
- });
- }
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- $("#searchBillNo").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //保存信息
- $("#saveAccountHead").off("click").on("click", function () {
- if(!$('#accountHeadFM').form('validate')){
- return;
- } else {
- if (!$('#OrganId').combobox('getValue')) {
- $.messager.alert('提示', '请选择付款单位!', 'warning');
- return;
- }
- if (!$('#HandsPersonId').val()) {
- $.messager.alert('提示', '请选择经手人!', 'warning');
- return;
- }
- var OrganId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val());
- var TotalPrice = $("#accountHeadFM .datagrid-footer [field='EachAmount'] div").text();
- OrganId = $('#OrganId').combobox('getValue');
- saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId);
- }
- });
-
- //打印单据
- $("#printAccountHeadShow").off("click").on("click",function(){
- var tableString = $("#accountHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event)
- {
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="BillNo"||obj.id=="BillTime"))
- {
- $("#saveAccountHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchBillNo"))
- {
- $("#searchBtn").click();
- }
- });
-}
-
-function showAccountHeadDetails(pageNo,pageSize){
- $.ajax({
- type:"get",
- url: "/accountHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- billNo: $.trim($("#searchBillNo").val()),
- beginTime: $("#searchBeginTime").val(),
- endTime: $("#searchEndTime").val()
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#accountHeadFM .datagrid-body");
- var footer =$("#accountHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
-
- //修改金额,自动计算单价和合计
- body.find("[field='EachAmount']").find(input).off("keyup").on("keyup",function(){
- var TotalPrice = 0;
- var EachAmount =$(this).val()-0; //金额
- body.find("[field='EachAmount']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + EachAmount;
- footer.find("[field='EachAmount']").find("div").text((TotalPrice).toFixed(2));
- });
- },500);
-}
-
-//结束编辑
-function endEditing() {
- var edField = "";
- if(!itemType){
- edField = "InOutItemId";
- edName = "InOutItemName";
- }
- else {
- edField = "AccountId";
- edName = "AccountName";
- }
- if (editIndex == undefined) { return true }
- if ($('#accountData').datagrid('validateRow', editIndex)) {
- var ed = $('#accountData').datagrid('getEditor', {index: editIndex, field: edField});
- var textName =null;
- if($(ed.target)){
- textName = $(ed.target).combobox('getText');
- }
- $('#accountData').datagrid('getRows')[editIndex][edName] = textName;
- $('#accountData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#accountData').datagrid('selectRow', index)
- .datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#accountData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append() {
- if (endEditing()) {
- $('#accountData').datagrid('appendRow', {});
- editIndex = $('#accountData').datagrid('getRows').length - 1;
- $('#accountData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function removeit() {
- if (editIndex == undefined) { return }
- $('#accountData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#accountData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData() {
- var row = $('#accountData').datagrid('getRows');
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if(!itemType){
- if (row[i].InOutItemId == "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- else{
- if (row[i].AccountId == "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-function saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId) {
- if (editIndex != undefined) {
- $('#accountData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- if (!CheckData())
- return false;
- var inserted = $("#accountData").datagrid('getChanges', "inserted");
- var deleted = $("#accountData").datagrid('getChanges', "deleted");
- var updated = $("#accountData").datagrid('getChanges', "updated");
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: {
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- info : JSON.stringify({
- Type: listType,
- BillNo: $.trim($("#BillNo").val()),
- BillTime: $.trim($("#BillTime").val()),
- AccountId: $.trim($("#AccountId").val()),
- ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
- TotalPrice: TotalPrice, //合计
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Remark: $.trim($("#Remark").val())
- }),
- listType: listType
- },
- success: function (tipInfo)
- {
- if (tipInfo) {
- $.messager.alert('提示','保存成功!','info');
- $('#accountHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showAccountHeadDetails(opts.pageNumber, opts.pageSize);
- }
- else{
-
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- error: function (XmlHttpRequest, textStatus, errorThrown)
- {
- $.messager.alert('提示',XmlHttpRequest.responseText,'error');
- }
- });
-}
\ No newline at end of file
diff --git a/erp_web/js/pages/financial/money_out.js b/erp_web/js/pages/financial/money_out.js
deleted file mode 100644
index d7dbdb43..00000000
--- a/erp_web/js/pages/financial/money_out.js
+++ /dev/null
@@ -1,890 +0,0 @@
-//初始化界面
-var listTitle ="付款单列表";
-var listType = "付款";
-var itemType = true; //隐藏当前列
-var moneyType = false; //显示当前列
-var payTypeTitle = "无标题";
-var inOrOut = "";
-var organUrl = "/supplier/findBySelect_sup"; //供应商接口
-var amountNum = "FK";
-$(function(){
- initSystemData_person(); //经手人数据
- initSelectInfo_person(); //经手人信息
- initSystemData_account(); //账户数据
- initSelectInfo_account(); //账户信息
- initSupplier(); //供应商
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
- $("#searchBtn").click();
-});
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null)
- {
- options = "";
- for(var i = 0 ;i < accountList.length; i++)
- {
- var account = accountList[i];
- options += '';
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//初始化单位信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- formatter: function(row){
- var opts = $(this).combobox('options');
- if(row[opts.textField]!=="非会员") {
- return row[opts.textField];
- }
- }
- });
-}
-
-//获取财务员
-function initSystemData_person(){
- var type = "财务员";
- $.ajax({
- type:"get",
- url: "/person/getPersonByType",
- data: {
- type: type
- },
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- personList = res.data.personList;
- }
- }
- });
-}
-//获取财务员
-function initSelectInfo_person(){
- var options = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="财务员")
- {
- options += '';
- }
- }
- $("#HandsPersonId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#accountHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- var organNameTitle = "收款单位";
- var organNameHidden = false;
- $('#tableData').datagrid({
- //width:700,
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //fitColumns:true,
- //单击行是否选中
- //checkOnSelect : false,
- pagination: true,
- //交替出现背景
- striped : true,
- //loadFilter: pagerFilter,
- pageSize: 5,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:90,formatter:function(value, rec,index) {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/7 10:48
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js
- */
- var str = '';
- var orgId = rec.organid ? rec.organid : 0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { field: 'organid',width:5, hidden:true},
- { title: organNameTitle,field: 'organname',width:140,hidden:organNameHidden},
- { title: '单据编号',field: 'billno',width:140},
- { title: '经手人',field: 'handspersonname',width:80},
- { title: '单据时间 ',field: 'billtime',width:140},
- { title: '合计',field: 'totalprice',width:80},
- { title: '备注',field: 'remark',width:100}
- ]],
- toolbar:[
- {
- id:'addAccountHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addAccountHead();
- }
- },
- {
- id:'deleteAccountHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteAccountHead();
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化表格数据-明细列表-编辑状态
-function initTableData_account(type,TotalPrice){
- $('#accountData').datagrid({
- height:280,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: payTypeTitle,field: 'InOutItemId',width:230,hidden:itemType,
- formatter:function(value,row,index){
- return row.InOutItemName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'InOutItemName',
- method:'get',
- url: "/inOutItem/findBySelect?type=" + inOrOut
- }
- }
- },
- { title: '账户名称',field: 'AccountId',width:230,hidden:moneyType,
- formatter:function(value,row,index){
- return row.AccountName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'AccountName',
- method:'get',
- url: "/account/findBySelect"
- }
- }
- },
- { title: '金额',field: 'EachAmount',editor:'validatebox',width:70},
- { title: '备注',field: 'Remark',editor:'validatebox',width:150}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- removeit(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/accountItem/getDetailList',
- data: {
- headerId: accountHeadID
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var EachAmount = 0;
- if(type === "edit") {
- EachAmount = TotalPrice;
- }
- var array = [];
- array.push({
- "EachAmount": EachAmount
- });
- data.footer = array;
- $("#accountData").datagrid('loadData',data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-
-//初始化表格数据-明细列表-查看状态
-function initTableData_account_show(TotalPrice){
- $('#accountDataShow').datagrid({
- height:280,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { title: payTypeTitle, field: 'InOutItemName', width:230, hidden:itemType},
- { title: '账户名称', field: 'AccountName', width:230, hidden:moneyType},
- { title: '金额',field: 'EachAmount',width:70},
- { title: '备注',field: 'Remark',width:150}
- ]],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/accountItem/getDetailList',
- data: {
- headerId: accountHeadID
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var EachAmount = TotalPrice;
- var array = [];
- array.push({
- "EachAmount": EachAmount
- });
- data.footer = array;
- $("#accountDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showAccountHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除财务信息
-function deleteAccountHead(accountHeadID, thisOrganId, totalPrice){
- $.messager.confirm('删除确认','确定要删除此财务信息吗?',function(r)
- {
- if (r)
- {
- $.ajax({
- type:"post",
- url: "/accountHead/batchDeleteAccountHeadByIds",
- dataType: "json",
- data:{
- ids: accountHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=accountHeadID;
- jsondata.deleteType='2';
- var type='single';
- batDeleteAccountHeadForceConfirm(res,"/accountHead/batchDeleteAccountHeadByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
-
- }
- });
-}
-
-//批量删除财务信息
-function batDeleteAccountHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条财务信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1)
- {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
-
- //批量删除
- $.ajax({
- type:"post",
- url: "/accountHead/batchDeleteAccountHeadByIds",
- dataType: "json",
- async : false,
- data: ({
- ids : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=ids;
- jsondata.deleteType='2';
- var type='batch';
- batDeleteAccountHeadForceConfirm(res,"/accountHead/batchDeleteAccountHeadByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- }
-}
-/**
- * 确认强制删除
- * */
-function batDeleteAccountHeadForceConfirm(res,url,jsondata) {
- $.messager.confirm('删除确认', res.msg, function (r) {
- if (r) {
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: (jsondata),
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- if(type=='batch'){
- $(":checkbox").attr("checked", false);
- }
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- return;
- }else {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示','删除财务信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-
-//增加
-function addAccountHead(){
- $('#accountHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#BillTime").val(thisDateTime);
- var thisNumber = getNowFormatDateNum(); //根据时间生成编号
- $("#BillNo").val(amountNum + thisNumber).focus();
- var addTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgAccountHead = "";
- accountHeadID = 0;
- initTableData_account("add"); //明细列表
- reject(); //撤销下、刷新材料列表
- url = '/accountHead/addAccountHeadAndDetail';
-
- //收预付款单据支持刷卡功能
- if(listType == "收预付款") {
- //当会员卡号长度超过10位后,自动点击下拉框,用于兼容刷卡器
- $("#OrganId").next().find("input").off("keyup").on("keyup",function(){
- if($(this).val().length === 10){
- setTimeout(function(){
- $(".combo-panel .combobox-item-selected").click();
- },500);
- }
- });
- }
-}
-
-//编辑信息
-function editAccountHead(index){
- // var accountHeadInfo = accountHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#BillNo").val(rowsdata.billno);
- $("#BillTime").val(rowsdata.billtime);
- $("#Remark").val(rowsdata.remark);
- $("#AccountId").val(rowsdata.accountid);
- $('#OrganId').combobox('setValue', rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#ChangeAmount").val(rowsdata.changeamount);
- var TotalPrice = rowsdata.totalprice;
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于收预付款
- var editTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- accountHeadID = rowsdata.id;
-
- initTableData_account("edit",TotalPrice); //明细列表
- reject(); //撤销下、刷新列表
- url = '/accountHead/updateAccountHeadAndDetail?id=' + rowsdata.id;
-}
-
-//查看信息
-function showAccountHead(index){
- // var accountHeadInfo = accountHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#BillNoShow").text(rowsdata.billno);
- $("#BillTimeShow").text(rowsdata.billtime);
- $("#RemarkShow").text(rowsdata.remark);
- $("#AccountIdShow").text(rowsdata.accountname);
- $('#OrganIdShow').text(rowsdata.organname);
- $("#HandsPersonIdShow").text(rowsdata.handspersonname);
- $("#ChangeAmountShow").text(rowsdata.rowsdata==undefined?'0':rowsdata.rowsdata);
- var TotalPrice = rowsdata.totalprice;
- var showTitle = listTitle.replace("列表","信息");
- $('#accountHeadDlgShow').dialog('open').dialog('setTitle','
查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- accountHeadID = rowsdata.id;
- initTableData_account_show(TotalPrice); //明细列表-查看状态
-}
-
-//绑定操作事件
-function bindEvent(){
- //搜索处理
- $("#searchBtn").unbind().bind({
- click:function()
- {
- showAccountHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh', {
- pageNumber:1,
- pageSize:initPageSize
- });
- }
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- $("#searchBillNo").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //保存信息
- $("#saveAccountHead").off("click").on("click", function () {
- if(!$('#accountHeadFM').form('validate')){
- return;
- } else {
- if (!$('#OrganId').combobox('getValue')) {
- $.messager.alert('提示', '请选择收款单位!', 'warning');
- return;
- }
- if (!$('#HandsPersonId').val()) {
- $.messager.alert('提示', '请选择经手人!', 'warning');
- return;
- }
- var OrganId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val());
- var TotalPrice = $("#accountHeadFM .datagrid-footer [field='EachAmount'] div").text();
- if (listType !== "转账") {
- OrganId = $('#OrganId').combobox('getValue');
- }
- if (listType === "支出" || listType === "转账") {
- //支出为负数
- ChangeAmount = 0 - ChangeAmount;
- }
- if (listType === "支出" || listType === "付款" || listType === "转账") {
- //支出和付款为负数
- TotalPrice = 0 - TotalPrice;
- }
-
- saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId);
- }
- });
-
- //打印单据
- $("#printAccountHeadShow").off("click").on("click",function(){
- var tableString = $("#accountHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event)
- {
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="BillNo"||obj.id=="BillTime"))
- {
- $("#saveAccountHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchBillNo"))
- {
- $("#searchBtn").click();
- }
- });
-}
-
-function showAccountHeadDetails(pageNo,pageSize){
- $.ajax({
- type:"get",
- url: "/accountHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- billNo: $.trim($("#searchBillNo").val()),
- beginTime: $("#searchBeginTime").val(),
- endTime: $("#searchEndTime").val()
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#accountHeadFM .datagrid-body");
- var footer =$("#accountHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
-
- //修改金额,自动计算单价和合计
- body.find("[field='EachAmount']").find(input).off("keyup").on("keyup",function(){
- var TotalPrice = 0;
- var EachAmount =$(this).val()-0; //金额
- body.find("[field='EachAmount']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + EachAmount;
- footer.find("[field='EachAmount']").find("div").text((TotalPrice).toFixed(2));
- });
- },500);
-}
-
-//结束编辑
-function endEditing() {
- var edField = "";
- if(!itemType){
- edField = "InOutItemId";
- edName = "InOutItemName";
- }
- else {
- edField = "AccountId";
- edName = "AccountName";
- }
- if (editIndex == undefined) { return true }
- if ($('#accountData').datagrid('validateRow', editIndex)) {
- var ed = $('#accountData').datagrid('getEditor', {index: editIndex, field: edField});
- var textName =null;
- if($(ed.target)){
- textName = $(ed.target).combobox('getText');
- }
- $('#accountData').datagrid('getRows')[editIndex][edName] = textName;
- $('#accountData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#accountData').datagrid('selectRow', index)
- .datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#accountData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append() {
- if (endEditing()) {
- $('#accountData').datagrid('appendRow', {});
- editIndex = $('#accountData').datagrid('getRows').length - 1;
- $('#accountData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function removeit() {
- if (editIndex == undefined) { return }
- $('#accountData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#accountData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData() {
- var row = $('#accountData').datagrid('getRows');
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if(!itemType){
- if (row[i].InOutItemId == "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- else{
- if (row[i].AccountId == "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-function saveAccountHeadAndDetail(listType,ChangeAmount,TotalPrice,OrganId) {
- if (editIndex != undefined) {
- $('#accountData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- if (!CheckData())
- return false;
- var inserted = $("#accountData").datagrid('getChanges', "inserted");
- var deleted = $("#accountData").datagrid('getChanges', "deleted");
- var updated = $("#accountData").datagrid('getChanges', "updated");
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: {
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- info : JSON.stringify({
- Type: listType,
- BillNo: $.trim($("#BillNo").val()),
- BillTime: $.trim($("#BillTime").val()),
- AccountId: $.trim($("#AccountId").val()),
- ChangeAmount: ChangeAmount, //付款/收款/优惠/实付
- TotalPrice: TotalPrice, //合计
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Remark: $.trim($("#Remark").val())
- }),
- listType: listType
- },
- success: function (tipInfo)
- {
- if (tipInfo) {
- $.messager.alert('提示','保存成功!','info');
- $('#accountHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showAccountHeadDetails(opts.pageNumber, opts.pageSize);
- }
- else{
-
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- error: function (XmlHttpRequest, textStatus, errorThrown)
- {
- $.messager.alert('提示',XmlHttpRequest.responseText,'error');
- }
- });
-}
\ No newline at end of file
diff --git a/erp_web/js/pages/manage/customer.js b/erp_web/js/pages/manage/customer.js
deleted file mode 100644
index 8b3ebb95..00000000
--- a/erp_web/js/pages/manage/customer.js
+++ /dev/null
@@ -1,706 +0,0 @@
-var listType = "客户"; //类型
-var listTypeEn ="Customer"; //英文类型
-//初始化界面
-$(function() {
- initTableData();
- ininPager();
- bindEvent();
-});
-
-
-
-//初始化表格数据
-function initTableData() {
- //改变宽度和高度
- $("#searchPanel").panel({width:webW-2});
- $("#tablePanel").panel({width:webW-2});
- $('#tableData').datagrid({
- //title:'单位列表',
- //iconCls:'icon-save',
- //width:700,
- height:heightInfo,
- nowrap: false,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //fitColumns:true,
- //单击行是否选中
- checkOnSelect : false,
- //交替出现背景
- striped : true,
- pagination: true,
- //自动截取数据
- //nowrap : true,
- //loadFilter: pagerFilter,
- pageSize: initPageSize,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:60,formatter:function(value, rec,index)
- {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/6 9:33
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js实现
- */
- var str = '';
- // var rowInfo = rec.id + 'AaBb' + rec.supplier +'AaBb' + rec.contacts + 'AaBb'+ rec.phonenum + 'AaBb'+ rec.email + 'AaBb'+ rec.beginneedget + 'AaBb'+ rec.beginneedpay + 'AaBb' + rec.isystem + 'AaBb' + rec.description+ 'AaBb' + rec.type
- // + 'AaBb' + rec.fax + 'AaBb' + rec.telephone + 'AaBb' + rec.address + 'AaBb' + rec.taxnum + 'AaBb' + rec.bankname + 'AaBb' + rec.accountnumber + 'AaBb' + rec.taxrate;
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: '名称',field: 'supplier',width:150},
- { title: '联系人', field: 'contacts',width:50,align:"center"},
- { title: '手机号码', field: 'telephone',width:100,align:"center"},
- { title: '电子邮箱',field: 'email',width:80,align:"center"},
- { title: '联系电话', field: 'phonenum',width:100,align:"center"},
- { title: '传真', field: 'fax',width:100,align:"center"},
- { title: '预付款',field: 'advancein',width:70,align:"center"},
- { title: '期初应收',field: 'beginneedget',width:70,align:"center"},
- { title: '期初应付',field: 'beginneedpay',width:70,align:"center"},
- { title: '税率(%)', field: 'taxrate',width:50,align:"center"},
- { title: '状态',field: 'enabled',width:70,align:"center",formatter:function(value){
- return value? "启用":"禁用";
- }}
- ]],
- toolbar:[
- {
- id:'addSupplier',
- text:'增加',
- iconCls:'icon-add',
- handler:function() {
- addSuppler();
- }
- },'-',
- {
- id:'deleteSupplier',
- text:'删除',
- iconCls:'icon-remove',
- handler:function() {
- batDeleteSupplier();
- }
- },'-',
- {
- id:'setEnable',
- text:'启用',
- iconCls:'icon-ok',
- handler:function() {
- setEnableFun();
- }
- },'-',
- {
- id:'setDisEnable',
- text:'禁用',
- iconCls:'icon-no',
- handler:function() {
- setDisEnableFun();
- }
- },'-',
- {
- id:'setInput',
- text:'导入',
- iconCls:'icon-excel',
- handler:function() {
- setInputFun();
- }
- },'-',
- {
- id:'setOutput',
- text:'导出',
- iconCls:'icon-excel',
- handler:function() {
- setOutputFun();
- }
- }
- ],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- showSupplierDetails(1,initPageSize);
-}
-
-
-//分页信息处理
-function ininPager() {
- try {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh', {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showSupplierDetails(pageNum,pageSize);
- }
- });
- }
- catch (e) {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除信息
-function deleteSupplier(id) {
- $.messager.confirm('删除确认','确定要删除此条信息吗?',function(r) {
- if (r) {
- // var supplierTotalInfo = supplierInfo.split("AaBb");
- $.ajax({
- type:"post",
- url: "/supplier/batchDeleteSupplierByIds",
- dataType: "json",
- data: ({
- ids : id
- }),
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=id;
- jsondata.deleteType='2';
- var type='single';
- batDeleteSupplierForceConfirm(res,"/supplier/batchDeleteSupplierByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-//批量删除单位
-function batDeleteSupplier() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条信息吗?',function(r) {
- if (r) {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1)
- {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- $.ajax({
- type:"post",
- url: "/supplier/batchDeleteSupplierByIds",
- dataType: "json",
- async : false,
- data: ({
- ids : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=ids;
- jsondata.deleteType='2';
- var type='batch';
- batDeleteSupplierForceConfirm(res,"/supplier/batchDeleteSupplierByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- }
-}
-/**
- * 确认强制删除
- * */
-function batDeleteSupplierForceConfirm(res,url,jsondata) {
- $.messager.confirm('删除确认', res.msg, function (r) {
- if (r) {
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: (jsondata),
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- if(type=='batch'){
- $(":checkbox").attr("checked", false);
- }
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- }else {
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- });
- }
- });
-}
-
-//批量启用
-function setEnableFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('启用提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('启用确认','确定要启用选中的' + row.length + '条信息吗?',function(r) {
- if (r) {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- $.ajax({
- type:"post",
- url: "/supplier/batchSetEnable",
- dataType: "json",
- async : false,
- data: ({
- enabled: true,
- supplierIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('启用提示', '启用信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('启用提示','启用信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- }
-}
-
-//批量禁用
-function setDisEnableFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('禁用提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('禁用确认','确定要禁用选中的' + row.length + '条信息吗?',function(r) {
- if (r) {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- $.ajax({
- type:"post",
- url: "/supplier/batchSetEnable",
- dataType: "json",
- async : false,
- data: ({
- enabled: false,
- supplierIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('禁用提示', '禁用信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('禁用提示','禁用信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- }
-}
-
-//导入数据
-function setInputFun(){
- //IE下不允许编辑 input=file的值 解决思路:重新克隆input=file,把这个input元素复制一个,然后将原来的删除。
- //在IE下复制元素的时候,其中的值是不会被复制的,所以就达到了清空文件域的目的了。
- //而在Firefox下,其中的值也会被一同复制,清空一下就做到兼容
- var fileUploadInput = $("#supplierFile");
- fileUploadInput.after(fileUploadInput.clone().val(""));
- fileUploadInput.remove();
- $("#isCheck").val(1);
- $('#importExcelDlg').dialog('open').dialog('setTitle','导入' + listType + '信息');
- $(".window-mask").css({ width: webW-20 ,height: webH});
- $("#supplierFile").focus();
-}
-
-//导出数据
-function setOutputFun(){
- var supplier = $.trim($("#searchSupplier").val());
- var phonenum = $.trim($("#searchPhonenum").val());
- var telephone = $.trim($("#searchTelephone").val());
- var description = $.trim($("#searchDesc").val());
- var browserType=getOs();
- window.location.href = "/supplier/exportExcel?browserType=" + browserType
- + "&supplier=" + supplier + "&type=" + listType + "&phonenum=" + phonenum + "&telephone=" + telephone + "&description=" + description;
-}
-
-//增加单位
-var url;
-var supplierID = 0;
-//保存编辑前的名称
-var oldSupplier = "";
-
-function addSuppler() {
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加'+listType+"信息");
- $(".window-mask").css({ width: webW ,height: webH});
- $("#supplier").focus();
- $('#supplierFM').form('clear');
- oldSupplier = "";
- supplierID = 0;
- url = '/supplier/add';
-}
-
-function bindEvent(){
- //导入excel对话框
- $('#importExcelDlg').dialog({
- width: 400,
- closed: true,
- cache: false,
- modal: true,
- collapsible:false,
- closable: true,
- buttons:'#dlg-buttons5'
- });
- //导入excel表格
- $("#saveimport").unbind().bind({
- click:function() {
- if($("#supplierFile").val().length == 0)
- {
- $.messager.alert('提示','请选择文件!','info');
- return;
- }
- $("#importExcelFM").submit();
- $('#importExcelDlg').dialog('close');
-
- $.messager.progress({
- title:'请稍候',
- msg:'数据处理ing...'
- });
- setTimeout(function(){
- $.messager.progress('close');
- var opts = $("#tableData").datagrid('options');
- showSupplierDetails(opts.pageNumber,opts.pageSize);
- },3300);
- }
- });
- //保存信息
- $("#saveSupplier").off("click").on("click", function () {
- if(validateForm("supplierFM")) {
- return;
- }
- if (checkSupplierName()) {
- return;
- }
- var reg = /^([0-9])+$/;
- var phonenum = $.trim($("#phonenum").val());
- if(phonenum.length>0 && !reg.test(phonenum)) {
- $.messager.alert('提示','电话号码只能是数字','info');
- $("#phonenum").val("").focus();
- return;
- }
- var beginNeedGet = $.trim($("#BeginNeedGet").val());
- var beginNeedPay = $.trim($("#BeginNeedPay").val());
- if(beginNeedGet && beginNeedPay) {
- $.messager.alert('提示','期初应收和期初应付不能同时输入','info');
- return;
- }
-
- var obj = $("#supplierFM").serializeObject();
- obj.type = listType;
- obj.enabled = 1;
- $.ajax({
- url: url,
- type:"post",
- dataType: "json",
- data:{
- info: JSON.stringify(obj)
- },
- success: function(res) {
- if(res && res.code === 200) {
- $('#supplierDlg').dialog('close');
- //加载完以后重新初始化
- var opts = $("#tableData").datagrid('options');
- showSupplierDetails(opts.pageNumber, opts.pageSize);
- }
- }
- });
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event) {
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件
- if(k == "13"&&(obj.id=="supplier" || obj.id=="contacts"|| obj.id=="phonenum"
- || obj.id=="email" || obj.id=="description" ))
- {
- $("#saveSupplier").click();
- }
-
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchSupplier" || obj.id=="searchContacts"|| obj.id=="searchPhonenum"
- || obj.id=="searchEmail" || obj.id=="searchDesc" ))
- {
- $("#searchBtn").click();
- }
- });
-
- //搜索处理
- $("#searchBtn").unbind().bind({
- click:function() {
- showSupplierDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh', {
- pageNumber:1,
- pageSize:initPageSize
- });
- }
- });
-
- $("#searchBtn").click();
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- $("#searchSupplier").val("");
- $("#searchType").val("");
- $("#searchPhonenum").val("");
- $("#searchTelephone").val("");
- $("#searchDesc").val("");
-
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
-}
-
-
-//编辑信息
-function editSupplier(index) {
- // var supplierInfo = supplierTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var beginNeedGet = rowsdata.beginneedget;
- var beginNeedPay = rowsdata.beginneedpay;
- var row = {
- supplier : rowsdata.supplier,
- contacts : (rowsdata.contacts).replace("undefined",""),
- phonenum : (rowsdata.phonenum).replace("undefined",""),
- email : (rowsdata.email).replace("undefined",""),
- BeginNeedGet : beginNeedGet == "0"? "":beginNeedGet,
- BeginNeedPay : beginNeedPay == "0"? "":beginNeedPay,
- AllNeedGet: "",
- AllNeedPay: "",
- description : (rowsdata.description).replace("undefined",""),
- type : rowsdata.type,
- fax : (rowsdata.fax).replace("undefined",""),
- telephone : (rowsdata.telephone).replace("undefined",""),
- address : (rowsdata.address).replace("undefined",""),
- taxNum : (rowsdata.taxnum).replace("undefined",""),
- bankName : (rowsdata.bankname).replace("undefined",""),
- accountNumber : (rowsdata.accountnumber).replace("undefined",""),
- taxRate : rowsdata.taxrate==undefined?"":rowsdata.taxrate
- };
- oldSupplier = rowsdata.supplier;
- $('#supplierDlg').dialog('open').dialog('setTitle','
编辑'+listType +"信息");
- $(".window-mask").css({ width: webW ,height: webH});
- $('#supplierFM').form('load',row);
- supplierID = rowsdata.id;
- //焦点在名称输入框==定焦在输入文字后面
- $("#supplier").val("").focus().val(rowsdata.supplier);
- url = '/supplier/update?id=' + rowsdata.id;
-
- //显示累计应收和累计应付
- var thisDateTime = getNowFormatDateTime(); //当前时间
- var supType = "customer";
- $.ajax({
- type:"get",
- url: "/depotHead/findTotalPay",
- dataType: "json",
- async: false,
- data: ({
- supplierId: rowsdata.id,
- endTime:thisDateTime,
- supType: supType
- }),
- success: function(res){
- if (res && res.code === 200 && res.data && res.data.rows && res.data.rows.getAllMoney !== "") {
- var moneyA = res.data.rows.getAllMoney.toFixed(2)-0;
- $.ajax({
- type:"get",
- url: "/accountHead/findTotalPay",
- dataType: "json",
- async: false,
- data: ({
- supplierId: rowsdata.id,
- endTime:thisDateTime,
- supType: supType
- }),
- success: function(res){
- if (res && res.code === 200 && res.data && res.data.rows && res.data.rows.getAllMoney !== "") {
- var moneyB = res.data.rows.getAllMoney.toFixed(2)-0;
- var money = moneyA+moneyB;
- var moneyBeginNeedGet = $("#BeginNeedGet").val()-0; //期初应收
- var moneyBeginNeedPay = $("#BeginNeedPay").val()-0; //期初应付
- money = (money + moneyBeginNeedGet - moneyBeginNeedPay).toFixed(2);
- $("#AllNeedGet").val(money); //累计应收
- }
- },
- error: function(){
- $.messager.alert('提示','网络异常请稍后再试!','error');
- return;
- }
- });
- }
- },
- error: function(){
- $.messager.alert('提示','网络异常请稍后再试!','error');
- return;
- }
- });
-}
-
-
-//检查单位名称是否存在 ++ 重名无法提示问题需要跟进
-function checkSupplierName() {
- var supplierName = $.trim($("#supplier").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(supplierName.length > 0 &&( oldSupplier.length ==0 || supplierName != oldSupplier)) {
- $.ajax({
- type:"get",
- url: "/supplier/checkIsNameExist",
- dataType: "json",
- async : false,
- data: ({
- id : supplierID,
- name : supplierName
- }),
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data && res.data.status) {
- flag = res.data.status;
- if (flag) {
- $.messager.alert('提示', '单位名称已经存在', 'info');
- return;
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('提示','检查单位名称是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
-}
-
-
-function showSupplierDetails(pageNo,pageSize) {
- var supplier = $.trim($("#searchSupplier").val());
- var phonenum = $.trim($("#searchPhonenum").val());
- var telephone = $.trim($("#searchTelephone").val());
- var description = $.trim($("#searchDesc").val());
- $.ajax({
- type:"get",
- url: "/supplier/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- supplier: supplier,
- type: listType,
- phonenum: phonenum,
- telephone: telephone,
- description: description
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- return;
- }
- });
-}
-
diff --git a/erp_web/js/pages/manage/member.js b/erp_web/js/pages/manage/member.js
deleted file mode 100644
index 1ffdd2b5..00000000
--- a/erp_web/js/pages/manage/member.js
+++ /dev/null
@@ -1,715 +0,0 @@
-var listType = "会员"; //类型
-var listTypeEn = "Member"; //英文类型
-//初始化界面
-$(function() {
- initTableData();
- ininPager();
- bindEvent();
-});
-
-
-//初始化表格数据
-function initTableData() {
- //改变宽度和高度
- $("#searchPanel").panel({width:webW-2});
- $("#tablePanel").panel({width:webW-2});
- $('#tableData').datagrid({
- //title:'单位列表',
- //iconCls:'icon-save',
- //width:700,
- height:heightInfo,
- nowrap: false,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //fitColumns:true,
- //单击行是否选中
- checkOnSelect : false,
- //交替出现背景
- striped : true,
- pagination: true,
- //自动截取数据
- //nowrap : true,
- //loadFilter: pagerFilter,
- pageSize: initPageSize,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:60,formatter:function(value, rec,index)
- {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/6 9:33
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js实现
- */
- var str = '';
- // var rowInfo = rec.id + 'AaBb' + rec.supplier +'AaBb' + rec.contacts + 'AaBb'+ rec.phonenum + 'AaBb'+ rec.email + 'AaBb'+ rec.beginneedget + 'AaBb'+ rec.beginneedpay + 'AaBb' + rec.isystem + 'AaBb' + rec.description+ 'AaBb' + rec.type
- // + 'AaBb' + rec.fax + 'AaBb' + rec.telephone + 'AaBb' + rec.address + 'AaBb' + rec.taxnum + 'AaBb' + rec.bankname + 'AaBb' + rec.accountnumber + 'AaBb' + rec.taxrate;
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: '名称',field: 'supplier',width:150},
- { title: '联系人', field: 'contacts',width:50,align:"center"},
- { title: '手机号码', field: 'telephone',width:100,align:"center"},
- { title: '电子邮箱',field: 'email',width:80,align:"center"},
- { title: '联系电话', field: 'phonenum',width:100,align:"center"},
- { title: '传真', field: 'fax',width:100,align:"center"},
- { title: '预付款',field: 'advancein',width:70,align:"center"},
- { title: '期初应收',field: 'beginneedget',width:70,align:"center"},
- { title: '期初应付',field: 'beginneedpay',width:70,align:"center"},
- { title: '税率(%)', field: 'taxrate',width:50,align:"center"},
- { title: '状态',field: 'enabled',width:70,align:"center",formatter:function(value){
- return value? "启用":"禁用";
- }}
- ]],
- toolbar:[
- {
- id:'addSupplier',
- text:'增加',
- iconCls:'icon-add',
- handler:function() {
- addSuppler();
- }
- },'-',
- {
- id:'deleteSupplier',
- text:'删除',
- iconCls:'icon-remove',
- handler:function() {
- batDeleteSupplier();
- }
- },'-',
- {
- id:'setEnable',
- text:'启用',
- iconCls:'icon-ok',
- handler:function() {
- setEnableFun();
- }
- },'-',
- {
- id:'setDisEnable',
- text:'禁用',
- iconCls:'icon-no',
- handler:function() {
- setDisEnableFun();
- }
- },'-',
- {
- id:'setInput',
- text:'导入',
- iconCls:'icon-excel',
- handler:function() {
- setInputFun();
- }
- },'-',
- {
- id:'setOutput',
- text:'导出',
- iconCls:'icon-excel',
- handler:function() {
- setOutputFun();
- }
- }
- ],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- showSupplierDetails(1,initPageSize);
-}
-
-
-//分页信息处理
-function ininPager() {
- try {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh', {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showSupplierDetails(pageNum,pageSize);
- }
- });
- }
- catch (e) {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除信息
-function deleteSupplier(id) {
- $.messager.confirm('删除确认','确定要删除此条信息吗?',function(r) {
- if (r) {
- // var supplierTotalInfo = supplierInfo.split("AaBb");
- $.ajax({
- type:"post",
- url: "/supplier/batchDeleteSupplierByIds",
- dataType: "json",
- data: ({
- ids : id
- }),
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=id;
- jsondata.deleteType='2';
- var type='single';
- batDeleteSupplierForceConfirm(res,"/supplier/batchDeleteSupplierByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-//批量删除单位
-function batDeleteSupplier() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条信息吗?',function(r) {
- if (r) {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1)
- {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- $.ajax({
- type:"post",
- url: "/supplier/batchDeleteSupplierByIds",
- dataType: "json",
- async : false,
- data: ({
- ids : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=ids;
- jsondata.deleteType='2';
- var type='batch';
- batDeleteSupplierForceConfirm(res,"/supplier/batchDeleteSupplierByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- }
-}
-/**
- * 确认强制删除
- * */
-function batDeleteSupplierForceConfirm(res,url,jsondata) {
- $.messager.confirm('删除确认', res.msg, function (r) {
- if (r) {
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: (jsondata),
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- if(type=='batch'){
- $(":checkbox").attr("checked", false);
- }
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- }else {
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- });
- }
- });
-}
-
-//批量启用
-function setEnableFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('启用提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('启用确认','确定要启用选中的' + row.length + '条信息吗?',function(r) {
- if (r) {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- $.ajax({
- type:"post",
- url: "/supplier/batchSetEnable",
- dataType: "json",
- async : false,
- data: ({
- enabled: true,
- supplierIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('启用提示', '启用信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('启用提示','启用信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- }
-}
-
-//批量禁用
-function setDisEnableFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('禁用提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('禁用确认','确定要禁用选中的' + row.length + '条信息吗?',function(r) {
- if (r) {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- $.ajax({
- type:"post",
- url: "/supplier/batchSetEnable",
- dataType: "json",
- async : false,
- data: ({
- enabled: false,
- supplierIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('禁用提示', '禁用信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('禁用提示','禁用信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- }
-}
-
-//导入数据
-function setInputFun(){
- //IE下不允许编辑 input=file的值 解决思路:重新克隆input=file,把这个input元素复制一个,然后将原来的删除。
- //在IE下复制元素的时候,其中的值是不会被复制的,所以就达到了清空文件域的目的了。
- //而在Firefox下,其中的值也会被一同复制,清空一下就做到兼容
- var fileUploadInput = $("#supplierFile");
- fileUploadInput.after(fileUploadInput.clone().val(""));
- fileUploadInput.remove();
- $("#isCheck").val(1);
- $('#importExcelDlg').dialog('open').dialog('setTitle','导入' + listType + '信息');
- $(".window-mask").css({ width: webW-20 ,height: webH});
- $("#supplierFile").focus();
-}
-
-//导出数据
-function setOutputFun(){
- var supplier = $.trim($("#searchSupplier").val());
- var phonenum = $.trim($("#searchPhonenum").val());
- var telephone = $.trim($("#searchTelephone").val());
- var description = $.trim($("#searchDesc").val());
- var browserType=getOs();
- window.location.href = "/supplier/exportExcel?browserType=" + browserType
- + "&supplier=" + supplier + "&type=" + listType + "&phonenum=" + phonenum + "&telephone=" + telephone + "&description=" + description;
-}
-
-//增加单位
-var url;
-var supplierID = 0;
-//保存编辑前的名称
-var oldSupplier = "";
-
-function addSuppler() {
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加'+listType+"信息");
- $(".window-mask").css({ width: webW ,height: webH});
- $("#supplier").focus();
- $('#supplierFM').form('clear');
- oldSupplier = "";
- supplierID = 0;
- url = '/supplier/add';
-}
-
-function bindEvent(){
- //导入excel对话框
- $('#importExcelDlg').dialog({
- width: 400,
- closed: true,
- cache: false,
- modal: true,
- collapsible:false,
- closable: true,
- buttons:'#dlg-buttons5'
- });
- //导入excel表格
- $("#saveimport").unbind().bind({
- click:function() {
- if($("#supplierFile").val().length == 0)
- {
- $.messager.alert('提示','请选择文件!','info');
- return;
- }
- $("#importExcelFM").submit();
- $('#importExcelDlg').dialog('close');
-
- $.messager.progress({
- title:'请稍候',
- msg:'数据处理ing...'
- });
- setTimeout(function(){
- $.messager.progress('close');
- var opts = $("#tableData").datagrid('options');
- showSupplierDetails(opts.pageNumber,opts.pageSize);
- },3300);
- }
- });
- //保存信息
- $("#saveSupplier").off("click").on("click", function () {
- if(validateForm("supplierFM")) {
- return;
- }
- if (checkSupplierName()) {
- return;
- }
- var reg = /^([0-9])+$/;
- var phonenum = $.trim($("#phonenum").val());
- if(phonenum.length>0 && !reg.test(phonenum)) {
- $.messager.alert('提示','电话号码只能是数字','info');
- $("#phonenum").val("").focus();
- return;
- }
- var beginNeedGet = $.trim($("#BeginNeedGet").val());
- var beginNeedPay = $.trim($("#BeginNeedPay").val());
- if(beginNeedGet && beginNeedPay) {
- $.messager.alert('提示','期初应收和期初应付不能同时输入','info');
- return;
- }
-
- var obj = $("#supplierFM").serializeObject();
- obj.type = listType;
- obj.enabled = 1;
- $.ajax({
- url: url,
- type:"post",
- dataType: "json",
- data:{
- info: JSON.stringify(obj)
- },
- success: function(res) {
- if(res && res.code === 200) {
- $('#supplierDlg').dialog('close');
- //加载完以后重新初始化
- var opts = $("#tableData").datagrid('options');
- showSupplierDetails(opts.pageNumber, opts.pageSize);
- }
- }
- });
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event) {
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件
- if(k == "13"&&(obj.id=="supplier" || obj.id=="contacts"|| obj.id=="phonenum"
- || obj.id=="email" || obj.id=="description" ))
- {
- $("#saveSupplier").click();
- }
-
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchSupplier" || obj.id=="searchContacts"|| obj.id=="searchPhonenum"
- || obj.id=="searchEmail" || obj.id=="searchDesc" ))
- {
- $("#searchBtn").click();
- }
- });
-
- //搜索处理
- $("#searchBtn").unbind().bind({
- click:function() {
- showSupplierDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh', {
- pageNumber:1,
- pageSize:initPageSize
- });
- }
- });
-
- $("#searchBtn").click();
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- $("#searchSupplier").val("");
- $("#searchType").val("");
- $("#searchPhonenum").val("");
- $("#searchTelephone").val("");
- $("#searchDesc").val("");
-
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
-}
-
-
-//编辑信息
-function editSupplier(index) {
- // var supplierInfo = supplierTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var beginNeedGet = rowsdata.beginneedget;
- var beginNeedPay = rowsdata.beginneedpay;
- var row = {
- supplier : rowsdata.supplier,
- contacts : (rowsdata.contacts).replace("undefined",""),
- phonenum : (rowsdata.phonenum).replace("undefined",""),
- email : (rowsdata.email).replace("undefined",""),
- BeginNeedGet : beginNeedGet == "0"? "":beginNeedGet,
- BeginNeedPay : beginNeedPay == "0"? "":beginNeedPay,
- AllNeedGet: "",
- AllNeedPay: "",
- description : (rowsdata.description).replace("undefined",""),
- type : rowsdata.type,
- fax : (rowsdata.fax).replace("undefined",""),
- telephone : (rowsdata.telephone).replace("undefined",""),
- address : (rowsdata.address).replace("undefined",""),
- taxNum : (rowsdata.taxnum).replace("undefined",""),
- bankName : (rowsdata.bankname).replace("undefined",""),
- accountNumber : (rowsdata.accountnumber).replace("undefined",""),
- taxRate : rowsdata.taxrate==undefined?"":rowsdata.taxrate
- };
- oldSupplier = rowsdata.supplier;
- $('#supplierDlg').dialog('open').dialog('setTitle','
编辑'+listType +"信息");
- $(".window-mask").css({ width: webW ,height: webH});
- $('#supplierFM').form('load',row);
- supplierID = rowsdata.id;
- //焦点在名称输入框==定焦在输入文字后面
- $("#supplier").val("").focus().val(rowsdata.supplier);
- url = '/supplier/update?id=' + rowsdata.id;
-
- //显示累计应收和累计应付
- var thisDateTime = getNowFormatDateTime(); //当前时间
- var supType = "customer";
- $.ajax({
- type:"get",
- url: "/depotHead/findTotalPay",
- dataType: "json",
- async: false,
- data: ({
- supplierId: rowsdata.id,
- endTime:thisDateTime,
- supType: supType
- }),
- success: function(res){
- if (res && res.code === 200 && res.data && res.data.rows && res.data.rows.getAllMoney !== "") {
- var moneyA = res.data.rows.getAllMoney.toFixed(2)-0;
- $.ajax({
- type:"get",
- url: "/accountHead/findTotalPay",
- dataType: "json",
- async: false,
- data: ({
- supplierId: rowsdata.id,
- endTime:thisDateTime,
- supType: supType
- }),
- success: function(res){
- if (res && res.code === 200 && res.data && res.data.rows && res.data.rows.getAllMoney !== "") {
- var moneyB = res.data.rows.getAllMoney.toFixed(2)-0;
- var money = moneyA+moneyB;
- var moneyBeginNeedGet = $("#BeginNeedGet").val()-0; //期初应收
- var moneyBeginNeedPay = $("#BeginNeedPay").val()-0; //期初应付
- /**
- * 会员该做什么操作呢?
- *
- * */
- if(listType === "客户"){
- money = (money + moneyBeginNeedGet - moneyBeginNeedPay).toFixed(2);
- $("#AllNeedGet").val(money); //累计应收
- }
- else if(listType === "供应商"){
- money = (money + moneyBeginNeedPay - moneyBeginNeedGet).toFixed(2);
- $("#AllNeedPay").val(money); //累计应付
- }
- }
- },
- error: function(){
- $.messager.alert('提示','网络异常请稍后再试!','error');
- return;
- }
- });
- }
- },
- error: function(){
- $.messager.alert('提示','网络异常请稍后再试!','error');
- return;
- }
- });
-}
-
-
-//检查单位名称是否存在 ++ 重名无法提示问题需要跟进
-function checkSupplierName() {
- var supplierName = $.trim($("#supplier").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(supplierName.length > 0 &&( oldSupplier.length ==0 || supplierName != oldSupplier)) {
- $.ajax({
- type:"get",
- url: "/supplier/checkIsNameExist",
- dataType: "json",
- async : false,
- data: ({
- id : supplierID,
- name : supplierName
- }),
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data && res.data.status) {
- flag = res.data.status;
- if (flag) {
- $.messager.alert('提示', '单位名称已经存在', 'info');
- return;
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('提示','检查单位名称是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
-}
-
-
-function showSupplierDetails(pageNo,pageSize) {
- var supplier = $.trim($("#searchSupplier").val());
- var phonenum = $.trim($("#searchPhonenum").val());
- var telephone = $.trim($("#searchTelephone").val());
- var description = $.trim($("#searchDesc").val());
- $.ajax({
- type:"get",
- url: "/supplier/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- supplier: supplier,
- type: listType,
- phonenum: phonenum,
- telephone: telephone,
- description: description
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- return;
- }
- });
-}
-
diff --git a/erp_web/js/pages/manage/vendor.js b/erp_web/js/pages/manage/vendor.js
deleted file mode 100644
index 2a4d0191..00000000
--- a/erp_web/js/pages/manage/vendor.js
+++ /dev/null
@@ -1,705 +0,0 @@
-//初始化界面
-var listType = "供应商"; //类型
-var listTypeEn = "Vendor"; //英文类型
-$(function() {
- initTableData();
- ininPager();
- bindEvent();
-});
-
-
-//初始化表格数据
-function initTableData() {
- //改变宽度和高度
- $("#searchPanel").panel({width:webW-2});
- $("#tablePanel").panel({width:webW-2});
- $('#tableData').datagrid({
- //title:'单位列表',
- //iconCls:'icon-save',
- //width:700,
- height:heightInfo,
- nowrap: false,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //fitColumns:true,
- //单击行是否选中
- checkOnSelect : false,
- //交替出现背景
- striped : true,
- pagination: true,
- //自动截取数据
- //nowrap : true,
- //loadFilter: pagerFilter,
- pageSize: initPageSize,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:60,formatter:function(value, rec,index)
- {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/6 9:33
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js实现
- */
- var str = '';
- // var rowInfo = rec.id + 'AaBb' + rec.supplier +'AaBb' + rec.contacts + 'AaBb'+ rec.phonenum + 'AaBb'+ rec.email + 'AaBb'+ rec.beginneedget + 'AaBb'+ rec.beginneedpay + 'AaBb' + rec.isystem + 'AaBb' + rec.description+ 'AaBb' + rec.type
- // + 'AaBb' + rec.fax + 'AaBb' + rec.telephone + 'AaBb' + rec.address + 'AaBb' + rec.taxnum + 'AaBb' + rec.bankname + 'AaBb' + rec.accountnumber + 'AaBb' + rec.taxrate;
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: '名称',field: 'supplier',width:150},
- { title: '联系人', field: 'contacts',width:50,align:"center"},
- { title: '手机号码', field: 'telephone',width:100,align:"center"},
- { title: '电子邮箱',field: 'email',width:80,align:"center"},
- { title: '联系电话', field: 'phonenum',width:100,align:"center"},
- { title: '传真', field: 'fax',width:100,align:"center"},
- { title: '预付款',field: 'advancein',width:70,align:"center"},
- { title: '期初应收',field: 'beginneedget',width:70,align:"center"},
- { title: '期初应付',field: 'beginneedpay',width:70,align:"center"},
- { title: '税率(%)', field: 'taxrate',width:50,align:"center"},
- { title: '状态',field: 'enabled',width:70,align:"center",formatter:function(value){
- return value? "启用":"禁用";
- }}
- ]],
- toolbar:[
- {
- id:'addSupplier',
- text:'增加',
- iconCls:'icon-add',
- handler:function() {
- addSuppler();
- }
- },'-',
- {
- id:'deleteSupplier',
- text:'删除',
- iconCls:'icon-remove',
- handler:function() {
- batDeleteSupplier();
- }
- },'-',
- {
- id:'setEnable',
- text:'启用',
- iconCls:'icon-ok',
- handler:function() {
- setEnableFun();
- }
- },'-',
- {
- id:'setDisEnable',
- text:'禁用',
- iconCls:'icon-no',
- handler:function() {
- setDisEnableFun();
- }
- },'-',
- {
- id:'setInput',
- text:'导入',
- iconCls:'icon-excel',
- handler:function() {
- setInputFun();
- }
- },'-',
- {
- id:'setOutput',
- text:'导出',
- iconCls:'icon-excel',
- handler:function() {
- setOutputFun();
- }
- }
- ],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- showSupplierDetails(1,initPageSize);
-}
-
-
-//分页信息处理
-function ininPager() {
- try {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh', {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showSupplierDetails(pageNum,pageSize);
- }
- });
- }
- catch (e) {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除信息
-function deleteSupplier(id) {
- $.messager.confirm('删除确认','确定要删除此条信息吗?',function(r) {
- if (r) {
- // var supplierTotalInfo = supplierInfo.split("AaBb");
- $.ajax({
- type:"post",
- url: "/supplier/batchDeleteSupplierByIds",
- dataType: "json",
- data: ({
- ids : id
- }),
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=id;
- jsondata.deleteType='2';
- var type='single';
- batDeleteSupplierForceConfirm(res,"/supplier/batchDeleteSupplierByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-//批量删除单位
-function batDeleteSupplier() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条信息吗?',function(r) {
- if (r) {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1)
- {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- $.ajax({
- type:"post",
- url: "/supplier/batchDeleteSupplierByIds",
- dataType: "json",
- async : false,
- data: ({
- ids : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- if(res && res.code == 601){
- var jsondata={};
- jsondata.ids=ids;
- jsondata.deleteType='2';
- var type='batch';
- batDeleteSupplierForceConfirm(res,"/supplier/batchDeleteSupplierByIds",jsondata,type);
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- }else{
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- }
-}
-/**
- * 确认强制删除
- * */
-function batDeleteSupplierForceConfirm(res,url,jsondata) {
- $.messager.confirm('删除确认', res.msg, function (r) {
- if (r) {
- $.ajax({
- type: "post",
- url: url,
- dataType: "json",
- data: (jsondata),
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- if(type=='batch'){
- $(":checkbox").attr("checked", false);
- }
- }else if(res && res.code == 600){
- $.messager.alert('删除提示', res.msg, 'error');
- }else {
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除信息失败,请稍后再试!', 'error');
- return;
- }
- });
- }
- });
-}
-
-//批量启用
-function setEnableFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('启用提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('启用确认','确定要启用选中的' + row.length + '条信息吗?',function(r) {
- if (r) {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- $.ajax({
- type:"post",
- url: "/supplier/batchSetEnable",
- dataType: "json",
- async : false,
- data: ({
- enabled: true,
- supplierIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('启用提示', '启用信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('启用提示','启用信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- }
-}
-
-//批量禁用
-function setDisEnableFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('禁用提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('禁用确认','确定要禁用选中的' + row.length + '条信息吗?',function(r) {
- if (r) {
- var ids = "";
- for(var i = 0;i < row.length; i ++) {
- if(i == row.length-1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- $.ajax({
- type:"post",
- url: "/supplier/batchSetEnable",
- dataType: "json",
- async : false,
- data: ({
- enabled: false,
- supplierIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('禁用提示', '禁用信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('禁用提示','禁用信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- }
-}
-
-//导入数据
-function setInputFun(){
- //IE下不允许编辑 input=file的值 解决思路:重新克隆input=file,把这个input元素复制一个,然后将原来的删除。
- //在IE下复制元素的时候,其中的值是不会被复制的,所以就达到了清空文件域的目的了。
- //而在Firefox下,其中的值也会被一同复制,清空一下就做到兼容
- var fileUploadInput = $("#supplierFile");
- fileUploadInput.after(fileUploadInput.clone().val(""));
- fileUploadInput.remove();
- $("#isCheck").val(1);
- $('#importExcelDlg').dialog('open').dialog('setTitle','导入' + listType + '信息');
- $(".window-mask").css({ width: webW-20 ,height: webH});
- $("#supplierFile").focus();
-}
-
-//导出数据
-function setOutputFun(){
- var supplier = $.trim($("#searchSupplier").val());
- var phonenum = $.trim($("#searchPhonenum").val());
- var telephone = $.trim($("#searchTelephone").val());
- var description = $.trim($("#searchDesc").val());
- var browserType=getOs();
- window.location.href = "/supplier/exportExcel?browserType=" + browserType
- + "&supplier=" + supplier + "&type=" + listType + "&phonenum=" + phonenum + "&telephone=" + telephone + "&description=" + description;
-}
-
-//增加单位
-var url;
-var supplierID = 0;
-//保存编辑前的名称
-var oldSupplier = "";
-
-function addSuppler() {
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加'+listType+"信息");
- $(".window-mask").css({ width: webW ,height: webH});
- $("#supplier").focus();
- $('#supplierFM').form('clear');
- oldSupplier = "";
- supplierID = 0;
- url = '/supplier/add';
-}
-
-function bindEvent(){
- //导入excel对话框
- $('#importExcelDlg').dialog({
- width: 400,
- closed: true,
- cache: false,
- modal: true,
- collapsible:false,
- closable: true,
- buttons:'#dlg-buttons5'
- });
- //导入excel表格
- $("#saveimport").unbind().bind({
- click:function() {
- if($("#supplierFile").val().length == 0)
- {
- $.messager.alert('提示','请选择文件!','info');
- return;
- }
- $("#importExcelFM").submit();
- $('#importExcelDlg').dialog('close');
-
- $.messager.progress({
- title:'请稍候',
- msg:'数据处理ing...'
- });
- setTimeout(function(){
- $.messager.progress('close');
- var opts = $("#tableData").datagrid('options');
- showSupplierDetails(opts.pageNumber,opts.pageSize);
- },3300);
- }
- });
- //保存信息
- $("#saveSupplier").off("click").on("click", function () {
- if(validateForm("supplierFM")) {
- return;
- }
- if (checkSupplierName()) {
- return;
- }
- var reg = /^([0-9])+$/;
- var phonenum = $.trim($("#phonenum").val());
- if(phonenum.length>0 && !reg.test(phonenum)) {
- $.messager.alert('提示','电话号码只能是数字','info');
- $("#phonenum").val("").focus();
- return;
- }
- var beginNeedGet = $.trim($("#BeginNeedGet").val());
- var beginNeedPay = $.trim($("#BeginNeedPay").val());
- if(beginNeedGet && beginNeedPay) {
- $.messager.alert('提示','期初应收和期初应付不能同时输入','info');
- return;
- }
-
- var obj = $("#supplierFM").serializeObject();
- obj.type = listType;
- obj.enabled = 1;
- $.ajax({
- url: url,
- type:"post",
- dataType: "json",
- data:{
- info: JSON.stringify(obj)
- },
- success: function(res) {
- if(res && res.code === 200) {
- $('#supplierDlg').dialog('close');
- //加载完以后重新初始化
- var opts = $("#tableData").datagrid('options');
- showSupplierDetails(opts.pageNumber, opts.pageSize);
- }
- }
- });
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event) {
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件
- if(k == "13"&&(obj.id=="supplier" || obj.id=="contacts"|| obj.id=="phonenum"
- || obj.id=="email" || obj.id=="description" ))
- {
- $("#saveSupplier").click();
- }
-
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchSupplier" || obj.id=="searchContacts"|| obj.id=="searchPhonenum"
- || obj.id=="searchEmail" || obj.id=="searchDesc" ))
- {
- $("#searchBtn").click();
- }
- });
-
- //搜索处理
- $("#searchBtn").unbind().bind({
- click:function() {
- showSupplierDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh', {
- pageNumber:1,
- pageSize:initPageSize
- });
- }
- });
-
- $("#searchBtn").click();
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- $("#searchSupplier").val("");
- $("#searchType").val("");
- $("#searchPhonenum").val("");
- $("#searchTelephone").val("");
- $("#searchDesc").val("");
-
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
-}
-
-
-//编辑信息
-function editSupplier(index) {
- // var supplierInfo = supplierTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var beginNeedGet = rowsdata.beginneedget;
- var beginNeedPay = rowsdata.beginneedpay;
- var row = {
- supplier : rowsdata.supplier,
- contacts : (rowsdata.contacts).replace("undefined",""),
- phonenum : (rowsdata.phonenum).replace("undefined",""),
- email : (rowsdata.email).replace("undefined",""),
- BeginNeedGet : beginNeedGet == "0"? "":beginNeedGet,
- BeginNeedPay : beginNeedPay == "0"? "":beginNeedPay,
- AllNeedGet: "",
- AllNeedPay: "",
- description : (rowsdata.description).replace("undefined",""),
- type : rowsdata.type,
- fax : (rowsdata.fax).replace("undefined",""),
- telephone : (rowsdata.telephone).replace("undefined",""),
- address : (rowsdata.address).replace("undefined",""),
- taxNum : (rowsdata.taxnum).replace("undefined",""),
- bankName : (rowsdata.bankname).replace("undefined",""),
- accountNumber : (rowsdata.accountnumber).replace("undefined",""),
- taxRate : rowsdata.taxrate==undefined?"":rowsdata.taxrate
- };
- oldSupplier = rowsdata.supplier;
- $('#supplierDlg').dialog('open').dialog('setTitle','
编辑'+listType +"信息");
- $(".window-mask").css({ width: webW ,height: webH});
- $('#supplierFM').form('load',row);
- supplierID = rowsdata.id;
- //焦点在名称输入框==定焦在输入文字后面
- $("#supplier").val("").focus().val(rowsdata.supplier);
- url = '/supplier/update?id=' + rowsdata.id;
-
- //显示累计应收和累计应付
- var thisDateTime = getNowFormatDateTime(); //当前时间
- var supType = "vendor";
- $.ajax({
- type:"get",
- url: "/depotHead/findTotalPay",
- dataType: "json",
- async: false,
- data: ({
- supplierId: rowsdata.id,
- endTime:thisDateTime,
- supType: supType
- }),
- success: function(res){
- if (res && res.code === 200 && res.data && res.data.rows && res.data.rows.getAllMoney !== "") {
- var moneyA = res.data.rows.getAllMoney.toFixed(2)-0;
- $.ajax({
- type:"get",
- url: "/accountHead/findTotalPay",
- dataType: "json",
- async: false,
- data: ({
- supplierId: rowsdata.id,
- endTime:thisDateTime,
- supType: supType
- }),
- success: function(res){
- if (res && res.code === 200 && res.data && res.data.rows && res.data.rows.getAllMoney !== "") {
- var moneyB = res.data.rows.getAllMoney.toFixed(2)-0;
- var money = moneyA+moneyB;
- var moneyBeginNeedGet = $("#BeginNeedGet").val()-0; //期初应收
- var moneyBeginNeedPay = $("#BeginNeedPay").val()-0; //期初应付
- money = (money + moneyBeginNeedPay - moneyBeginNeedGet).toFixed(2);
- $("#AllNeedPay").val(money); //累计应付
- }
- },
- error: function(){
- $.messager.alert('提示','网络异常请稍后再试!','error');
- return;
- }
- });
- }
- },
- error: function(){
- $.messager.alert('提示','网络异常请稍后再试!','error');
- return;
- }
- });
-}
-
-
-//检查单位名称是否存在 ++ 重名无法提示问题需要跟进
-function checkSupplierName() {
- var supplierName = $.trim($("#supplier").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(supplierName.length > 0 &&( oldSupplier.length ==0 || supplierName != oldSupplier)) {
- $.ajax({
- type:"get",
- url: "/supplier/checkIsNameExist",
- dataType: "json",
- async : false,
- data: ({
- id : supplierID,
- name : supplierName
- }),
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data && res.data.status) {
- flag = res.data.status;
- if (flag) {
- $.messager.alert('提示', '单位名称已经存在', 'info');
- return;
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('提示','检查单位名称是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
-}
-
-
-function showSupplierDetails(pageNo,pageSize) {
- var supplier = $.trim($("#searchSupplier").val());
- var phonenum = $.trim($("#searchPhonenum").val());
- var telephone = $.trim($("#searchTelephone").val());
- var description = $.trim($("#searchDesc").val());
- $.ajax({
- type:"get",
- url: "/supplier/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- supplier: supplier,
- type: listType,
- phonenum: phonenum,
- telephone: telephone,
- description: description
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- return;
- }
- });
-}
-
diff --git a/erp_web/js/pages/materials/allocation_out_list.js b/erp_web/js/pages/materials/allocation_out_list.js
deleted file mode 100644
index 34905267..00000000
--- a/erp_web/js/pages/materials/allocation_out_list.js
+++ /dev/null
@@ -1,2375 +0,0 @@
-//初始化界面
-var defDepotId = null;
-var kid = sessionStorage.getItem("userId");
-var pageType = getUrlParam('t'); //获取页面类型传值
-var depotList = null;
-var depotID = null;
-var supplierList = null;
-var supplierID = null;
-var personList = null;
-var personID = null;
-var ProjectSearch=null;
-var userBusinessList=null;
-var userdepot=null;
-var url;
-var depotHeadID = 0;
-var preTotalPrice = 0; //前一次加载的金额
-var orgDepotHead = "";
-var editIndex = undefined;
-/**默认编号有意义吗,不如空着吧*/
-var orgDefaultId=''; //单位默认编号
-var orgDefaultList; //存储查询出来的会员列表
-var accountList; //账户列表
-var outItemList; //支出项目列表
-var thisTaxRate = 0; //当前税率,选择供应商或者客户的时候设置
-var oldNumber = ""; //编辑前的单据编号
-var oldId = 0; //编辑前的单据Id
-var otherColumns = true; //明细中的‘别名’列是否显示
-var btnEnableList = getBtnStr(); //获取按钮的权限
-var mPropertyList = ""; //商品属性列表
-var defaultAccountId = 0; //默认账户id
-//改变宽度和高度
-$("#searchPanel").panel({width:webW-2});
-$("#tablePanel").panel({width:webW-2});
-var listTitle = "调拨出库列表"; //单据标题
-var depotString = "|"; //店铺id列表
-var listType = "出库"; //入库 出库
-var listSubType = "调拨"; //采购 销售等
-var payTypeTitle = "隐藏"; //付款 收款
-var organUrl = "/supplier/findBySelect_sup"; //组织数据接口地址
-var amountNum = "DBCK"; //单据编号开头字符
-$(function(){
- //初始化系统基础信息
- initSystemData_UB();
- initSelectInfo_UB();
- initSystemData_depot();
- initSelectInfo_depot();
- initSystemData_person();
- initSelectInfo_person();
- initSystemData_account();
- initSelectInfo_account();
- initSupplier(); //供应商
- initSalesman(); //销售人员
- initOutItemList(); //初始化支出项目
- initMProperty(); //初始化商品属性
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
-});
-//初始化系统基础信息
-function initSystemData_UB(){
- $.ajax({
- type:"get",
- url: "/userBusiness/getBasicData",
- data: ({
- KeyId:kid,
- Type:"UserDepot"
- }),
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if (res && res.code === 200) {
- userBusinessList = res.data.userBusinessList;
- }
- else {
- userBusinessList = null;
- }
- }
- });
-
-}
-//初始化页面选项卡
-function initSelectInfo_UB(){
-
- if(userBusinessList !=null)
- {
- if(userBusinessList.length>0)
- {
- //用户对应的仓库列表 [1][2][3]...
- userdepot =userBusinessList[0].value;
- }
- }
-}
-
-
-//初始化系统基础信息
-function initSystemData_depot(){
- $.ajax({
- type:"get",
- url: "/depot/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200){
- depotList = res.data;
- } else {
- $.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error');
- return;
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_depot(){
- var options = "";
-
- if(depotList !=null)
- {
- options = "";
- for(var i = 0 ;i < depotList.length;i++)
- {
- var depot = depotList[i];
-
- if(userdepot!=null)
- {
- if(userdepot.indexOf("["+depot.id+"]")!=-1)
- {
- if(depot.isDefault){
- defDepotId = depot.id;
- }
- options += '';
- depotString = depotString + depot.id + ",";
- }
- }
- if(depot.type === 1){
- depotString = depotString + depot.id + ",";
- }
- }
- depotString = depotString.substring(1, depotString.length-1);
- $("#ProjectId").empty().append(options);
- $("#AllocationProjectId").empty().append(options);
- $("#searchProjectId").empty().append('').append(options);
- }
-}
-
-//初始化供应商、客户、散户信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onLoadSuccess: function(res) {
- var data = $(this).combobox('getData');
- for(var i = 0; i<= data.length; i++){
- if(data && data[i] && data[i].supplier === "非会员"){
- orgDefaultId = data[i].id;
- }
- }
- },
- onSelect: function(rec){
- $.ajax({
- type:"get",
- url: "/supplier/findById",
- data: {
- supplierId: rec.id
- },
- dataType: "json",
- success: function (res){
- if(res && res.code === 200) {
- if(res.data && res.data[0]){
- thisTaxRate = res.data[0].taxRate; //设置当前的税率
- }
- }
- },
- error:function(){
-
- }
- });
- }
- });
-}
-
-//初始化销售人员
-function initSalesman(){
- $('#Salesman').combobox({
- url: "/person/getPersonByNumType?type=1",
- valueField:'id',
- textField:'name',
- multiple: true
- });
-}
-
-//初始化收入项目列表
-function initOutItemList(){
- $.ajax({
- type:"get",
- url: "/inOutItem/findBySelect?type=out",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res){
- if(res){
- outItemList = res;
- }
- },
- error:function(){
-
- }
- });
-}
-
-//初始化商品属性
-function initMProperty(){
- $.ajax({
- type: "get",
- url: "/materialProperty/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- name: ""
- }),
- currentPage: 1,
- pageSize: 100
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- var thisRows = res.data.page.rows;
- for (var i = 0; i < thisRows.length; i++) {
- if (thisRows[i].enabled) {
- mPropertyList += thisRows[i].nativename + ",";
- }
- }
- if (mPropertyList) {
- mPropertyList = mPropertyList.substring(0, mPropertyList.length - 1);
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化系统基础信息
-function initSystemData_person(){
- $.ajax({
- type:"get",
- url: "/person/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- personList = res.data.personList;
- }
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_person(){
- var options1 = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="仓管员")
- {
- options1 += '';
- }
- }
- $("#HandsPersonId").empty().append(options1);
- }
-}
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null){
- options = "";
- options += "";
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- if(account.isdefault) {
- defaultAccountId = account.id; //给账户赋值默认id
- }
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#depotHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- if(pageType === "skip") {
- var oldRowInfo = sessionStorage.getItem("rowInfo");
- editDepotHead(oldRowInfo); //自动弹出编辑框,带缓存数据
- }
- var hideType = undefined;
- var isHiddenStatus = true;
- if(payTypeTitle === "隐藏"){
- hideType = true; //隐藏当前列
- }
- var tableToolBar = [
- {
- id:'addDepotHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addDepotHead();
- }
- },
- {
- id:'deleteDepotHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteDepotHead();
- }
- }
- ];
- //如果允许的按钮列表中存在就显示,3-代表审核|反审核的权限
- if(btnEnableList && btnEnableList.indexOf(3)>-1){
- isHiddenStatus = false; //显示
- tableToolBar.push({
- id:'okDepotHead',
- text:'审核',
- iconCls:'icon-ok',
- handler:function() {
- setStatusFun();
- }
- },
- {
- id:'undoDepotHead',
- text:'反审核',
- iconCls:'icon-undo',
- handler:function() {
- setUnStatusFun();
- }
- });
- }
- else {
- isHiddenStatus = true; //隐藏
- }
- var isShowLastMoneyColumn = true; //是否显示优惠后金额和价税合计,true为隐藏,false为显示
- var isShowOrganNameColumn = true; //是否显示供应商、客户等信息,true为隐藏,false为显示
- var organNameTitle = ""; //组织名称标题
- var opWidth = 90; //操作宽度
- $('#tableData').datagrid({
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: true,
- //交替出现背景
- striped : true,
- pageSize: 10,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:opWidth,
- formatter:function(value, rec,index) {
- var str = '';
- var orgId = rec.organid? rec.organid:0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
- { title: '单据编号',field: 'number',width:135, formatter:function (value,rec) {
- if(rec.linknumber) {
- return value + "[转]";
- } else {
- return value;
- }
- }
- },
- { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
- if(value) {
- return value.replace(",",",");
- }
- }
- },
- { title: '单据日期',field: 'opertimeStr',width:130},
- { title: '操作员',field: 'operpersonname',width:60},
- { title: '金额合计',field: 'totalprice',width:60},
- { title: '含税合计',field: 'totaltaxlastmoney',hidden:isShowLastMoneyColumn,width:60,formatter:function(value,rec){
- return (rec.discountmoney + rec.discountlastmoney).toFixed(2);
- }
- },
- { title: '优惠后金额',field: 'discountlastmoney',hidden:isShowLastMoneyColumn,width:80},
- { title: payTypeTitle,field: 'changeamount',width:50,hidden:hideType},
- { title: '状态',field: 'status',hidden:isHiddenStatus, width:70,align:"center",formatter:function(value){
- if(value === "0") {
- return "未审核";
- } else if(value === "1") {
- return "已审核";
- } else if(value === "2") {
- }
- }
- }
- ]],
- toolbar:tableToolBar,
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//查找库存的方法
-function findStockNumById(depotId, mId, monthTime, body, input, ratio, type){
- var thisRatio = 1; //比例
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (rec) {
- if(rec && rec.code === 200 && rec.data && rec.data[0]) {
- var loadRatio = 1; //在单位输入框上面加载比例字段
- if(rec.data[0].unit) { //如果存在计量单位信息
- loadRatio = 1;
- }
- else{
- var unitName = rec.data[0].unitName;
- if(unitName) {
- thisRatio = unitName.substring(unitName.indexOf(":")+1).replace(")","");
- unitName = unitName.substring(0, unitName.indexOf("("));
- }
- }
- //查询库存
- $.ajax({
- type: "get",
- url: '/depotItem/findStockNumById',
- data:{
- projectId: depotId,
- materialId: mId
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if (res.data && res.data.page && res.data.page[0]) {
- var thisStock = res.data.page[0].thisSum;
- if (type == "select") { //选择下拉框的时候
- if (ratio != undefined && ratio != 1) {
- loadRatio = ratio;
- }
- }
- else if (type == "click") { //点击库存的时候
- if (ratio != undefined) {
- loadRatio = ratio;
- }
- }
- thisStock = (thisStock / loadRatio).toFixed(2);
- body.find("[field='Stock']").find(input).val(thisStock).attr("data-stock", res.data.page[0].thisSum); //加载库存数据
- }
- else {
- body.find("[field='Stock']").find(input).val(0).attr("data-stock", 0); //加载库存数据
- }
- body.find("[field='Stock']").find(input).prop("readonly", "readonly"); //设置库存数据为只读
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
- }
- },
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- }
- });
-}
-//优惠率、合计的统计方法
-function statisticsFun(body,UnitPrice,OperNumber,footer,taxRate){
- var TotalPrice = 0;
- var taxLastMoneyTotal = 0;
- //金额的合计
- body.find("[field='AllPrice']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + UnitPrice*OperNumber;
- footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); //金额的合计
- //价税合计的总计
- body.find("[field='TaxLastMoney']").each(function(){
- if($(this).find("div").text()!==""){
- taxLastMoneyTotal = taxLastMoneyTotal + (parseFloat($(this).find("div").text().toString())-0);
- }
- });
- taxLastMoneyTotal = taxLastMoneyTotal + (UnitPrice*OperNumber*(1+taxRate/100));
- footer.find("[field='TaxLastMoney']").find("div").text((taxLastMoneyTotal).toFixed(2)); //价税合计的页脚总计
- var discount = $("#Discount").val(); //优惠率
- var discountMoney = (taxLastMoneyTotal*discount/100).toFixed(2);
- $("#DiscountMoney").val(discountMoney);//优惠金额
- var discountLastMoney = (taxLastMoneyTotal*(1-discount/100)).toFixed(2)
- $("#DiscountLastMoney").val(discountLastMoney);//优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
-}
-//初始化表格数据-商品列表-编辑状态
-function initTableData_material(type,TotalPrice){
- var body,footer,input; //定义表格和文本框
- var ratio = 1; //比例-品名专用
- var ratioDepot = 1; //比例-仓库用
- var monthTime = getNowFormatMonth();
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var depotHeadName = ""; //仓库名称
- var depotUrl = ""; //仓库接口地址
- var depotTextField = ""; //仓库下拉名称
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var anotherDepotUrl = ""; //对方仓库接口地址
- var anotherDepotTextField = "";
- isShowAnotherDepot = false; //调拨时候显示对方仓库
- anotherDepotHeadName = "调入仓库";
- anotherDepotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- anotherDepotTextField = "depotName";
- depotHeadName = "仓库名称";
- depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- depotTextField = "depotName";
- var isShowTaxColumn = false; //是否显示税率相关的列,true为隐藏,false为显示
- isShowTaxColumn = true; //隐藏
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialData').datagrid({
- height:245,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: '商品类型',field: 'MType',editor:'validatebox',hidden:isShowMaterialTypeColumn,width:80},
- { title: depotHeadName, field: 'DepotId', editor: 'validatebox', width: 90,
- formatter: function (value, row, index) {
- return row.DepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: depotTextField,
- method: 'get',
- url: depotUrl,
- onSelect:function(rec){
- var depotId = rec.id;
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- if(mId){
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratioDepot, type);
- }
- }
- }
- }
- },
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialId',width:230,
- formatter:function(value,row,index){
- return row.MaterialName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'MaterialName',
- method:'get',
- url: "/material/findBySelect",
- panelWidth: 300, //下拉框的宽度
- //全面模糊匹配,过滤字段
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onBeforeLoad: function(param){
- param.mpList = mPropertyList; //商品属性
- },
- onSelect:function(rec){
- if(rec) {
- var mId = rec.Id;
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (res) {
- if(res && res.code === 200 && res.data && res.data[0]) {
- var retailPrice = res.data[0].retailprice-0; //零售价格
- var presetPriceOne = res.data[0].presetpriceone-0; //预计采购价
- var presetPriceTwo = res.data[0].presetpricetwo-0; //批发价
- var firstInUnit = res.data[0].firstinunit; //首选入库单位
- var firstOutUnit = res.data[0].firstoutunit; //首选出库单位
- var basicPresetPriceOne = ""; //多单位-入库-基础价格
- var basicPresetPriceTwo = ""; //多单位-出库-基础价格
- var retailPriceOne = ""; //多单位-入库-零售价格
- var otherPresetPriceOne = ""; //多单位-入库-其他价格
- var otherPresetPriceTwo = ""; //多单位-出库-其他价格
- var retailPriceTwo = ""; //多单位-出库-零售价格
- var basicUnit = ""; //基础单位
- var otherUnit = ""; //其他单位
- if(!res.data[0].unit){
- var ps = res.data[0].pricestrategy;
- var psObj = JSON.parse(ps);
- basicPresetPriceOne = psObj[0].basic.PresetPriceOne-0;
- basicPresetPriceTwo = psObj[0].basic.PresetPriceTwo-0;
- retailPriceOne = psObj[0].basic.RetailPrice-0;
- otherPresetPriceOne = psObj[1].other.PresetPriceOne-0;
- otherPresetPriceTwo = psObj[1].other.PresetPriceTwo-0;
- retailPriceTwo = psObj[1].other.RetailPrice-0;
- basicUnit = psObj[0].basic.Unit;
- otherUnit = psObj[1].other.Unit;
- }
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- if(res.data[0].unit){ //如果存在计量单位信息
- ratio = 1; //重置比例为1
- body.find("[field='Unit']").find(input).val(res.data[0].unit); //设置-计量单位信息
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- body.find("[field='Unit']").find(input).off("click"); //移除点击事件
- body.find("[field='Unit']").find(input).attr("data-ratio",ratio); //修改比例缓存信息
- }
- else {
- var unitName = res.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- var loadRatio = 1; //在单位输入框上面加载比例字段
- body.find("[field='Unit']").find(input).val(unitSetInput).attr("data-ratio", loadRatio); //设置-首选单位
-
- body.find("[field='Unit']").find(input).off("click").on("click",function(){
- if(basicUnit && otherUnit) {
- var self = this;
- //定义模版
- var temp = "
";
- temp +="
";
- temp +="- " + basicUnit + "
";
- temp +="- " + otherUnit + "
";
- temp +="
";
- temp +="
";
- if($('.unit-list').length){
- $('.unit-list').remove(); //如果存在计量单位列表先移除
- }
- else {
- $(self).after(temp); //加载列表信息
- }
- //计量单位列表的单击事件
- $('.unit-list ul li').off("click").on("click",function(){
- var unit = $(this).text();
- var thisRatio = $(this).attr("data-ratio"); //获取比例
- $(self).val(unit).attr("data-ratio", thisRatio);
- $(self).keyup(); //模拟键盘操作
- $('.unit-list').remove(); //移除计量单位列表
- var stock = body.find("[field='Stock']").find(input).attr("data-stock"); //从缓存中取值
- var type = $(this).attr("data-type");
- var UnitPrice = 0;
- if(type === "basic"){
- UnitPrice = basicPresetPriceTwo;
- body.find("[field='Stock']").find(input).val(stock); //修改库存
- }
- else if(type === "other"){
- UnitPrice = otherPresetPriceTwo;
- body.find("[field='Stock']").find(input).val((stock/ratio).toFixed(2)); //修改库存
- }
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //获取数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击空白处移除计量单位列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.unit-list').remove(); //移除计量单位列表
- });
- }
- });
- }
- var detailPrice = 0; //明细列表-单价
- if(res.data[0].unit) { //如果存在计量单位信息
- detailPrice = presetPriceTwo;
- }
- else {
- if(firstOutUnit==basicUnit) {
- detailPrice = basicPresetPriceTwo;
- }
- else if(firstOutUnit==otherUnit){
- detailPrice = otherPresetPriceTwo;
- }
- }
- body.find("[field='OperNumber']").find(input).val(1); //数量初始化为1
- //单价和总价赋值
- if(!detailPrice) {
- detailPrice = 0;
- }
- body.find("[field='UnitPrice']").find(input).val(detailPrice);
- body.find("[field='AllPrice']").find(input).val(detailPrice);
- var taxRate = body.find("[field='TaxRate']").find(input).val()-0; //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((detailPrice*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,detailPrice,1,footer,taxRate);
-
- //查询库存信息
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- if(depotId) {
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, loadRatio, type);
- }
- }
- },
- error: function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- }
- });
- }
- }
- }
- }
- },
- { title: '库存',field: 'Stock',editor:'validatebox',width:70},
- { title: anotherDepotHeadName, field: 'AnotherDepotId',editor:'validatebox',hidden:isShowAnotherDepot,width:90,
- formatter: function (value, row, index) {
- return row.AnotherDepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: anotherDepotTextField,
- method: 'get',
- url: anotherDepotUrl
- }
- }
- },
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率(%)',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batchDel(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = 0;
- var TaxLastMoney = 0;
- var DiscountMoney = $("#DiscountMoney").val()-0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoney").val()-0; //优惠后金额
- if(type === "edit") {
- AllPrice = TotalPrice;
- TaxLastMoney = DiscountMoney + DiscountLastMoney;
- }
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": TaxLastMoney
- });
- data.footer = array;
- $("#materialData").datagrid('loadData',data);
- //如果是订单跳转到采购或销售
- if(pageType === "skip") {
- var skipList = $("#depotHeadFM .datagrid-body tr");
- //逐条自动点击每行数据
- skipList.each(function (i) {
- setTimeout(function () {
- skipList.eq(i).find("[field='Stock']").click();
- },(i+1)*1000);
- });
- }
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//初始化表格数据-商品列表-查看状态
-function initTableData_material_show(TotalPrice){
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var depotHeadName = ""; //仓库的列的标题
- isShowAnotherDepot = false; //调拨时候显示对方仓库
- anotherDepotHeadName = "调入仓库";
- depotHeadName = "仓库名称";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialDataShow').datagrid({
- height:245,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- onClickRow: onClickRow,
- columns:[[
- { title: '商品类型',field: 'MType',width:80, hidden:isShowMaterialTypeColumn},
- { title: depotHeadName,field: 'DepotName',editor:'validatebox',width:90},
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialName',width:230},
- { title: anotherDepotHeadName,field: 'AnotherDepotName',hidden:isShowAnotherDepot,width:90},
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validattebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = TotalPrice;
- var DiscountMoney = $("#DiscountMoneyShow").text() - 0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoneyShow").text() - 0; //优惠后金额
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": DiscountMoney + DiscountLastMoney
- });
- data.footer = array;
- $("#materialDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showDepotHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除单据信息
-function deleteDepotHead(depotHeadID, thisOrganId, totalPrice, status){
- if(status == "1" || status == "2") {
- $.messager.alert('删除提示','已审核和已转的单据不能删除!','warning');
- return;
- }
- $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
- if (r) {
- $.ajax({
- type:"post",
- // url: "/depotHead/" + depotHeadID + "/delete",
- url: "/depotHead/deleteDepotHeadAndDetail",
- dataType: "json",
- data:{
- id: depotHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-//订单转采购或销售
-function skipDepotHead(index, status){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- if(status == "0" || status == "2") {
- $.messager.alert('提示','未审核和已转的单据禁止操作!','warning');
- } else {
- sessionStorage.setItem("rowInfo", JSON.stringify(rowsdata)); //将单据信息存入缓存中
- }
-}
-
-//批量删除单据信息
-function batDeleteDepotHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条单据信息吗?',function(r)
- {
- if (r) {
- var ids = "";
- for (var i = 0; i < row.length; i++) {
- if (i == row.length - 1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- if (ids) {
- //批量删除
- $.ajax({
- type: "post",
- url: "/depotHead/batchDeleteDepotHeadAndDetail",
- dataType: "json",
- async: false,
- data: ({
- ids: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除单据信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('删除提示','没有能删除的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量审核
-function setStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('审核确认','确定要审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: "1",
- depotHeadIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('审核提示', '审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('审核提示','审核信息异常,请稍后再试!','error');
- return;
- }
- });
- } else {
- $.messager.alert('审核提示','没有能审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量反审核
-function setUnStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('反审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('反审核确认','确定要反审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type: "post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async: false,
- data: ({
- status: "0",
- depotHeadIDs: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('反审核提示', '反审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('反审核提示', '反审核信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('反审核提示','没有能反审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//生成单据编号
-function buildNumber() {
- $.ajax({
- type: "get",
- url: "/depotHead/buildNumber",
- success:function(res){
- if(res && res.code === 200){
- var obj = res.data;
- var defaultNumber = obj.DefaultNumber;
- var newNumber = amountNum + defaultNumber;
- $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
- }
- },
- error:function(){
- $.messager.alert('提示','生成单据编号失败!','error');
- }
- });
-}
-
-//新增信息
-function addDepotHead(){
- $('#depotHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- buildNumber(); //生成单据编号
- //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为0
- $("#Discount").val(0);
- $("#DiscountMoney").val(0);
- $("#DiscountLastMoney").val(0);
- $("#ChangeAmount").val(0);
- $("#Debt").val(0);
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- var addTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgDepotHead = "";
- depotHeadID = 0;
- initTableData_material("add"); //商品列表
- reject(); //撤销下、刷新商品列表
- $("#addOrgan").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加供应商信息');
- $('#supplierFM').form('clear');
- });
-
- $("#addMember").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加会员信息');
- $('#supplierFM').form('clear');
- });
- $("#addCustomer").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加客户信息');
- $('#supplierFM').form('clear');
- });
- url = '/depotHead/addDepotHeadAndDetail';
-
-}
-
-//编辑信息
-function editDepotHead(index, status){
- if(status == "1" || status == "2") {
- $.messager.alert('编辑提示','已审核和已转的单据不能编辑!','warning');
- return;
- }
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata ='';
- if(Number(index).toString()=='NaN'){
- rowsdata=$.parseJSON(index);
- }else{
- rowsdata=$("#tableData").datagrid("getRows")[index];
- }
- $("#ProjectId").focus().val(rowsdata.projectid);
- var ProjectId=rowsdata.projectid;
- if(ProjectId!='') {
- initSystemData_person(ProjectId);
- initSelectInfo_person();
- }
- var TotalPrice = rowsdata.totalprice; //合计金额
- if(pageType === "skip") { //从订单跳转过来
- buildNumber(); //生成单据编号
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- $("#LinkNumber").val(rowsdata.number); //关联订单号
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- $("#DiscountLastMoney").val(TotalPrice); //优惠后金额
- $("#ChangeAmount").val(TotalPrice).attr("data-changeamount", TotalPrice);
- } else {
- $("#Number").val(rowsdata.number).attr("data-defaultNumber",rowsdata.number);
- $("#OperTime").val(rowsdata.opertimeStr);
- $("#LinkNumber").val(rowsdata.linknumber==undefined?"":rowsdata.linknumber); //关联订单号
- $("#AccountId").val(rowsdata.accountid); //账户Id
- $("#DiscountLastMoney").val(rowsdata.discountlastmoney==undefined?"0.00":rowsdata.discountlastmoney); //优惠后金额
- $("#ChangeAmount").val(rowsdata.changeamount).attr("data-changeamount", rowsdata.changeamount);
- }
- $('#OrganId').combobox('setValue', rowsdata.organid==undefined?'':rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#Remark").val(rowsdata.remark);
- $("#Discount").val(rowsdata.discount==undefined?"0":rowsdata.discount);
- $("#DiscountMoney").val(rowsdata.discountmoney==undefined?"0.00":rowsdata.discountmoney);
- $("#Debt").val(Number((rowsdata.discountlastmoney==undefined?'0.00':rowsdata.discountlastmoney-rowsdata.changeamount)).toFixed(2));
- $("#AccountDay").val(rowsdata.accountday==undefined?"":rowsdata.accountday); //结算天数
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于扣预付款
- $("#AllocationProjectId").val(rowsdata.allocationprojectid);
- oldNumber = rowsdata.number; //记录编辑前的单据编号
- oldId = rowsdata.id; //记录单据Id
- var editTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- depotHeadID = rowsdata.id;
-
-
-
- //采购入库、销售出库的多账户加载
- if(rowsdata.accountidlist!=undefined && rowsdata.accountmoneylist!=undefined){
- $("#AccountId").val("many"); //下拉框选中多账户
- var accountArr = rowsdata.accountidlist.split(",");
- var accountMoneyArr = rowsdata.accountmoneylist.split(",");
- accountMoneyArr = changeListFmtPlus(accountMoneyArr) //将数组单个金额中的数值转为正数
- $("#AccountId").attr("data-accountArr", JSON.stringify(accountArr)).attr("data-accountMoneyArr", JSON.stringify(accountMoneyArr)); //json数据存储
- $(".many-account-ico").show(); //显示多账户的ico图标
- }
-
- //采购入库、销售出库的费用数据加载
- if(rowsdata.othermoneylist &&rowsdata.othermoneyitem){
- $("#OtherMoney").val(rowsdata.othermoney==undefined?"0":rowsdata.othermoney); //采购费用、销售费用
- var itemArr = rowsdata.othermoneylist.split(",");
- var itemMoneyArr = rowsdata.othermoneyitem.split(",");
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
-
- initTableData_material("edit",TotalPrice); //商品列表
- reject(); //撤销下、刷新商品列表
- if(pageType === "skip") {
- url = '/depotHead/addDepotHeadAndDetail'; //如果是从订单跳转过来,则此处为新增的接口
- //jshjshjsh
- $("#depotHeadFM .datagrid-body").find("[field='DepotId']").click();
- } else {
- url = '/depotHead/updateDepotHeadAndDetail?id=' + rowsdata.id; //更新接口
- }
-}
-
-//查看信息
-function showDepotHead(index){
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var manyAccountMoney = 0; //多账户合计-零售
- $("#ProjectIdShow").text(rowsdata.projectName);
- $("#NumberShow").text(rowsdata.number);
- $("#OperTimeShow").text(rowsdata.opertimeStr);
- $('#OrganIdShow').text(rowsdata.organName==undefined?'':rowsdata.organName);
- $("#HandsPersonIdShow").text(rowsdata.handsPersonName);
- if(rowsdata.accountName && rowsdata.accountName!=undefined){
- $("#AccountIdShow").text(rowsdata.accountName); //结算账户
- } else {
- var accountArr = (rowsdata.accountidlist==undefined?"":rowsdata.accountidlist).split(","); //账户id列表
- var accountMoneyArr =(rowsdata.accountmoneylist==undefined?"":rowsdata.accountmoneylist).split(","); //账户金额列表
- var accountIdShow = "";
- for(var j =0;j 查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- depotHeadID = rowsdata.id;
- initTableData_material_show(TotalPrice); //商品列表-查看状态
-}
-
-//绑定操作事件
-function bindEvent(){
- showDepotHeadDetails(1,initPageSize); //初始化时自动查询
- //搜索处理
- $("#searchBtn").off("click").on("click",function(){
- showDepotHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh',
- {
- pageNumber:1,
- pageSize:initPageSize
- });
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- //$("#searchProjectId").val("");
- $("#searchState").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //检查单据编号是否存在
- function checkDepotHeadNumber() {
- var thisNumber = $.trim($("#Number").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(thisNumber.length > 0 &&( oldNumber.length ==0 || thisNumber != oldNumber))
- {
- $.ajax({
- type:"get",
- url: "/depotHead/checkIsNumberExist",
- dataType: "json",
- async : false,
- data: ({
- DepotHeadID : oldId,
- Number : thisNumber
- }),
- success: function (tipInfo)
- {
- flag = tipInfo;
- if(tipInfo)
- {
- $.messager.alert('提示','抱歉,该单据编号已经存在','warning');
- return;
- }
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','检查单据编号是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
- //保存信息
- /**
- * 2019-01-25
- * 我对这个方法的实现结果存在严重怀疑,决定重构
- * 有如下疑点:
- * 1、保存完主表,返回结果后,再发起请求去操作子表,如何保证事务的一致性(业务数据一致性)
- * 2、保存完主表后,再通过selectmax的方式去获取主表主键id完全就是看人品的不可靠的思路
- * 修改计划:
- * 2019-01-25修改零售出库相关操作
- * 修改方式,重写url,将主从表操作合并
- *
- *
- * **/
- $("#saveDepotHead").off("click").on("click",function(){
- if(!$('#depotHeadFM').form('validate')){
- return;
- }
- else {
- //如果初始编号被修改了,就要判断单据编号是否存在
- if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
- //调用查询单据编号是否重名的方法
- if(checkDepotHeadNumber()){
- return;
- }
- }
- if (editIndex != undefined) {
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- //进行明细的校验
- if(depotHeadID ==0) {
- //新增模式下
- if (!CheckData("add")) {
- return;
- }
- }
- else {
- //编辑模式下
- if (!CheckData("edit")) {
- return;
- }
- }
- var OrganId = null, ProjectId = null,AllocationProjectId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val())-0;
- var TotalPrice = $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text();
- if($('#OrganId').length){
- OrganId = $('#OrganId').combobox('getValue');
- }
- var accountMoneyList = $("#AccountId").attr("data-accountmoneyarr"); //账户金额列表-多账户
- var accountMoneyArr;
- if(accountMoneyList) {
- accountMoneyList = accountMoneyList.replace("[","").replace("]","").toString();
- var reg=new RegExp("\"","g"); //创建正则RegExp对象
- accountMoneyList = accountMoneyList.replace(reg,""); //替换所有的双引号
- accountMoneyArr = accountMoneyList.split(","); //转为数组
- }
- //零售时候,可以从会员预付款中扣款
- var thisPayType = "现付";
- var SalesmanStr = "";
- var getAccountID = $.trim($("#AccountId").val());
- if($("#AccountId").val() === "many"){ //多账户
- getAccountID = null;
- }
- var infoStr=JSON.stringify({
- Type: listType,
- SubType: listSubType,
- ProjectId: ProjectId,
- AllocationProjectId: AllocationProjectId,
- DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
- Number: $.trim($("#Number").val()),
- LinkNumber: $.trim($("#LinkNumber").val()),
- OperTime: $("#OperTime").val(),
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Salesman: SalesmanStr, //销售人员
- AccountId: getAccountID,
- ChangeAmount: ChangeAmount, //付款/收款
- TotalPrice: TotalPrice, //合计
- PayType: thisPayType, //现付/预付款
- Remark: $.trim($("#Remark").val()),
- AccountIdList: $("#AccountId").attr("data-accountarr"), //账户列表-多账户
- AccountMoneyList: accountMoneyArr ? JSON.stringify(accountMoneyArr) : "", //账户金额列表-多账户
- Discount: $.trim($("#Discount").val()),
- DiscountMoney: $.trim($("#DiscountMoney").val()),
- DiscountLastMoney: $.trim($("#DiscountLastMoney").val()),
- OtherMoney: $.trim($("#OtherMoney").val()), //采购费用、销售费用
- OtherMoneyList: $("#OtherMoney").attr("data-itemarr"), //支出项目列表-涉及费用
- OtherMoneyItem: $("#OtherMoney").attr("data-itemmoneyarr"), //支出项目金额列表-涉及费用
- AccountDay: $("#AccountDay").val() //结算天数
- });
- /**
- * 零售出库,单独操作
- * */
- if(url.indexOf("/depotHead/addDepotHeadAndDetail")>=0){
- addDepotHeadAndDetail(url,infoStr);
- return;
- }else if(url.indexOf("/depotHead/updateDepotHeadAndDetail")>=0){
- updateDepotHeadAndDetail(url,infoStr,preTotalPrice);
- return;
- }
- }
- });
-
- //打印单据
- $("#printDepotHeadShow").off("click").on("click",function(){
- var tableString = $("#depotHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event){
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="State"||obj.id=="Number"))
- {
- $("#saveDepotHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber"||obj.id=="searchMaterial"))
- {
- $("#searchBtn").click();
- }
- });
-
- //优惠率输入框事件
- $("#Discount").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountNum = $(this).val();
- var discountMoney = (discountNum/100*totalPrice).toFixed(2);
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#DiscountMoney").val(discountMoney); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //优惠金额输入框事件
- $("#DiscountMoney").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountMoney = $(this).val();
- var discount = (discountMoney/totalPrice).toFixed(2)*100;
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#Discount").val(discount); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //付款、收款输入框事件
- $("#ChangeAmount").off("keyup").on("keyup",function(){
- var discountLastMoney = $("#DiscountLastMoney").val();
- var changeAmount = $(this).val();
- var debtMoney = (discountLastMoney - changeAmount).toFixed(2);
- $("#Debt").val(debtMoney); //本次欠款
- });
-
- //多账户结算窗口弹出事件
- function depotHeadAccountDlgFun(){
- $('#depotHeadAccountDlg').dialog('open').dialog('setTitle','
多账户结算');
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").remove(); //先移除输入栏目
- $("#accountMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#depotHeadAccountDlg .tabs-tmp .account-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#depotHeadAccountDlg .tabs-tmp tbody").html();
- var accountDlgHead = $("#depotHeadAccountDlg .account-head-tmp");
- accountDlgHead.after(contentTmp);
- }
-
- //获取账户信息
- function accountDlgFun() {
- var options = "";
- if(accountList !=null){
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- }
- $(".account-id-dlg").empty().append("").append(options);
- }
- }
- accountDlgFun(); //获取账户信息
- $("#depotHeadAccountDlg .tabs-tmp").hide(); //隐藏模板
-
- //账户金额输入框事件-多账户
- $("#depotHeadAccountDlg .account-dlg .account-money-dlg").off("keyup").on("keyup",function(){
- var totalAccoutNum = 0;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var eachAccountMoney = $(this).find(".account-money-dlg").val()-0;
- totalAccoutNum += eachAccountMoney;
- });
- $("#accountMoneyTotalDlg").text(totalAccoutNum);
- });
-
- //结算多账户列表的切换事件
- $("#depotHeadAccountDlg .account-dlg .account-id-dlg").off("change").on("change",function(){
- var selectAccount = $(this).children('option:selected').text();
- if(selectAccount === ""){
- var thisMoneyDom = $(this).closest(".account-content-tmp").find(".account-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text() - 0;
- $("#accountMoneyTotalDlg").text(accountMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //账户为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveDepotHeadAccountDlg").off("click").on("click", function(){
- //完成多账户的json数据存储
- var accountArr = []; //账户id数组
- var accountMoneyArr = []; //账户金额数组
- var errorIndex = -1;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var thisAccId = $(this).find(".account-id-dlg").val();
- var thisAccMoney = $(this).find(".account-money-dlg").val();
- if(!thisAccId && thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && !thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && thisAccMoney) {
- accountArr.push(thisAccId);
- accountMoneyArr.push(thisAccMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var discountLastMoneyNum =$("#DiscountLastMoney").val()-0; //优惠后金额
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text()-0; //本次付款或者收款
- if(accountMoneyTotal===0){
- $.messager.alert('错误提示',"请填写金额后保存",'warning');
- return;
- }
- if(accountArr.length && accountMoneyArr.length) {
- $("#AccountId").attr("data-accountArr",JSON.stringify(accountArr)).attr("data-accountMoneyArr",JSON.stringify(accountMoneyArr)); //json数据存储
- }
- $("#ChangeAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
- $("#Debt").val((discountLastMoneyNum-accountMoneyTotal).toFixed(2)); //本次欠款
- $("#depotHeadAccountDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#AccountId").attr("data-accountArr")){
- $("#depotHeadAccountDlg").dialog('close');
- }
- else {
- $("#depotHeadAccountDlg").dialog('close');
- $("#AccountId").val("").removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- }
- //多账户-取消按钮
- $("#cancelDepotHeadAccountDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //多账户-右上角的关闭按钮
- $("#depotHeadAccountDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
- }
- //点击多账户,弹出输入框
- $("#AccountId").off("change").on("change",function(){
- var selectText = $(this).children('option:selected').text();
- if(selectText === "多账户"){
- $("#ChangeAmount").prop("readonly","readonly");
- depotHeadAccountDlgFun();
- $(".many-account-ico").show(); //显示多账户小图标
- }
- else{
- $(this).removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- });
-
- //结算账户-多账户小图标-点击事件
- $(".many-account-ico").off("click").on("click",function(){
- depotHeadAccountDlgFun();
- //给弹窗赋值-多账户数据
- var accountArr = $("#AccountId").attr("data-accountArr");
- accountArr = JSON.parse(accountArr);
- var accountMoneyArr = $("#AccountId").attr("data-accountMoneyArr");
- accountMoneyArr = JSON.parse(accountMoneyArr);
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".account-id-dlg").val(accountArr[index]);
- $(this).find(".account-money-dlg").val(accountMoneyArr[index]);
- });
- $("#accountMoneyTotalDlg").text($("#ChangeAmount").val());
- });
-
- //点击采购费用、销售费用的事件
- $(".other-money-ico").off("click").on("click",function(){
- $('#otherMoneyDlg').dialog('open').dialog('setTitle','
'+ listSubType +'费用');
- $("#otherMoneyDlg .money-dlg .money-content-tmp").remove(); //先移除输入栏目
- $("#otherMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#otherMoneyDlg .tabs-tmp .money-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#otherMoneyDlg .tabs-tmp tbody").html();
- var moneyDlgHead = $("#otherMoneyDlg .money-head-tmp");
- moneyDlgHead.after(contentTmp);
- }
-
- //获取支出项目信息
- function moneyDlgFun() {
- var options = "";
- if(outItemList !=null){
- for(var i = 0 ;i < outItemList.length;i++) {
- var money = outItemList[i];
- options += '';
- }
- $(".money-id-dlg").empty().append("").append(options);
- }
- }
- moneyDlgFun(); //获取支出项目信息
- $("#otherMoneyDlg .tabs-tmp").hide(); //隐藏模板
-
- //支出项目的金额输入框事件
- $("#otherMoneyDlg .money-dlg .other-money-dlg").off("keyup").on("keyup",function(){
- var totalMoneyNum = 0;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var eachOtherMoney = $(this).find(".other-money-dlg").val()-0;
- totalMoneyNum += eachOtherMoney;
- });
- $("#otherMoneyTotalDlg").text(totalMoneyNum);
- });
-
- //支出项目列表的切换事件
- $("#otherMoneyDlg .money-dlg .money-id-dlg").off("change").on("change",function(){
- var selectItem = $(this).children('option:selected').text();
- if(selectItem === ""){
- var thisMoneyDom = $(this).closest(".money-content-tmp").find(".other-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text() - 0;
- $("#otherMoneyTotalDlg").text(otherMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //支出项目为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveOtherMoneyDlg").off("click").on("click", function(){
- //完成支出项目的json数据存储
- var itemArr = []; //支出项目id数组
- var itemMoneyArr = []; //支出项目金额数组
- var errorIndex = -1;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var thisId = $(this).find(".money-id-dlg").val();
- var thisMoney = $(this).find(".other-money-dlg").val();
- if(!thisId && thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && !thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && thisMoney) {
- itemArr.push(thisId);
- itemMoneyArr.push(thisMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text()-0; //合计金额
- if(otherMoneyTotal === 0){ //0的时候清空缓存数据
- $("#OtherMoney").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr");
- }
- if(itemArr.length && itemMoneyArr.length) {
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
- $("#OtherMoney").val(otherMoneyTotal); //给采购费用、销售费用赋值
- $("#otherMoneyDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#OtherMoney").attr("data-itemArr")){
- $("#otherMoneyDlg").dialog('close');
- }
- else {
- $("#otherMoneyDlg").dialog('close');
- $("#OtherMoney").val("").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr"); //将下拉置空并把缓存参数清空
- }
- }
- //费用-取消按钮
- $("#cancelOtherMoneyDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //费用-右上角的关闭按钮
- $("#otherMoneyDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
-
- //给弹窗赋值-采购费用、销售费用数据
- var itemArr = $("#OtherMoney").attr("data-itemArr");
- itemArr = JSON.parse(itemArr);
- var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr");
- itemMoneyArr = JSON.parse(itemMoneyArr);
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".money-id-dlg").val(itemArr[index]);
- if(itemMoneyArr[index]!="undefined"){
- $(this).find(".other-money-dlg").val(itemMoneyArr[index]);
- }
- });
- $("#otherMoneyTotalDlg").text($("#OtherMoney").val());
- });
-
-}
-
-function showDepotHeadDetails(pageNo,pageSize){
- var materialParam = $.trim($("#searchMaterial").val());
- var beginTime = $.trim($("#searchBeginTime").val());
- var endTime = $.trim($("#searchEndTime").val());
- if(beginTime) {
- beginTime = beginTime + ' 00:00:00';
- }
- if(endTime) {
- endTime = endTime + ' 23:59:59';
- }
- $.ajax({
- type: "get",
- url: "/depotHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- subType: listSubType,
- state: $.trim($("#searchState").val()),
- number: $.trim($("#searchNumber").val()),
- beginTime: beginTime,
- endTime: endTime,
- materialParam: materialParam,
- depotIds: depotString
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#depotHeadFM .datagrid-body");
- var footer =$("#depotHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
- //点击商品下拉框,自动加载数量、单价、金额
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //点击库存文本框,字段计算库存
- body.find("[field='Stock']").find(input).off("click").on("click",function(){
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- var monthTime = getNowFormatMonth();
- if(depotId && mId){
- var ratio = body.find("[field='Unit']").find(input).attr("data-ratio");
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //在新增的时候,这个ratio有值;在编辑的时候,这个ratio为undefined
- var type = "click"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratio, type);
- }
- else{
- body.find("[field='Stock']").find(input).val(0).attr("data-stock",0); //加载库存数据
- }
- });
- //修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计
- body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber =$(this).val()-0; //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
-
- });
- //修改单价,自动计算金额和合计
- body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice =$(this).val()-0; //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击单价,自动提示参考价格列表
- body.find("[field='UnitPrice']").find(input).off("click").on("click",function(){
- var self = this;
- var mValue = body.find("[field='MaterialId'] .combo-value").attr("value"); //获取选中的商品id
- if(!mValue) {
- return;
- }
- else {
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mValue - 0
- },
- success: function(res){
- if(res && res.rows && res.rows[0]) {
- var retailPrice = res.rows[0].RetailPrice;
- var presetPriceOne = res.rows[0].PresetPriceOne;
- var presetPriceTwo = res.rows[0].PresetPriceTwo;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- 批发价:" + presetPriceTwo + "
";
- temp +="- 零售价:" + retailPrice + "
";
- temp +="
";
- temp +="
";
- if($('.price-list').length){
- $('.price-list').remove(); //如果存在价格列表先移除
- }
- else {
- if(presetPriceTwo != undefined){ //多单位的商品
- $(self).after(temp); //加载列表信息
- }
- }
- $('.price-list ul li').off("click").on("click",function(){
- var price = $(this).text();
- price = price.substring(price.indexOf(":") + 1);
- $(self).val(price);
- $(self).keyup(); //模拟键盘操作
- $('.price-list').remove(); //移除价格列表
- });
- //点击空白处移除价格列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.price-list').remove(); //移除价格列表
- });
- }
- },
- error: function(){
- $.messager.alert('错误提示','查询商品信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- //修改含税单价,自动计算单价、金额、税额、价税合计和合计
- body.find("[field='TaxUnitPrice']").find(input).off("keyup").on("keyup",function(){
- var TaxUnitPrice =$(this).val()-0; //含税单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var UnitPrice = TaxUnitPrice/(1+taxRate/100); //计算单价
- body.find("[field='UnitPrice']").find(input).val((UnitPrice).toFixed(2)); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改金额,自动计算单价、税额、价税合计和合计
- body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var AllPrice =$(this).val()-0; //金额
- var UnitPrice = (AllPrice/OperNumber).toFixed(2);
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税率,自动计算含税单价、税额、价税合计和合计
- body.find("[field='TaxRate']").find(input).off("keyup").on("keyup",function(){
- var taxRate =$(this).val()-0; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税额,自动计算税率、含税单价、价税合计和合计
- body.find("[field='TaxMoney']").find(input).off("keyup").on("keyup",function(){
- var taxMoney =$(this).val()-0; //税额
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = taxMoney/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改价税合计,自动计算税率、含税单价、税额和合计
- body.find("[field='TaxLastMoney']").find(input).off("keyup").on("keyup",function(){
- var taxLastMoney =$(this).val()-0; //价税合计
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = (taxLastMoney-AllPrice)/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
-
- //加载税率
- if(thisTaxRate) {
- body.find("[field='TaxRate']").find(input).val(thisTaxRate);
- }
- else {
- body.find("[field='TaxRate']").find(input).val(0); //默认为0
- }
-
- //在商品类型加载 组装件、普通子件
- var mType = body.find("[field='MType']");
- var rowListLength = mType.find(input).closest(".datagrid-row").attr("datagrid-row-index");
- var mTypeValue = "组合件";
- if(rowListLength > 0){
- mTypeValue = "普通子件";
- }
- },500);
-}
-
-//结束编辑
-function endEditing() {
- if (editIndex == undefined) { return true }
- if ($('#materialData').datagrid('validateRow', editIndex)) {
- //仓库信息
- var edDepot = $('#materialData').datagrid('getEditor', {index:editIndex,field:'DepotId'});
- var DepotName = $(edDepot.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName;
- //商品信息
- var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'});
- var MaterialName = $(edMaterial.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName;
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#materialData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append(){
- if (endEditing()) {
- $('#materialData').datagrid('appendRow', {DepotId:defDepotId});
- editIndex = $('#materialData').datagrid('getRows').length - 1;
- $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function batchDel(){
- /**
- * 重写一下删除的逻辑
- * 获取所有选中行,直接从列表中移除
- * 点击保存时,将需要后台删除的数据提交到服务器
- * **/
- /**
- * create by: qiankunpingtai
- * create time: 2019/3/20 16:26
- * description:
- * 这个地方比较坑的,花了一个多小时才搞明白为什么
- * 1、删除之前必须先调用endEditing结束编辑
- * 2、如果只是调用endEditing结束编辑那么正在编辑行的被选中状态会被去掉
- * 所以要在调用endEditing先获取选中的行
- */
- //如果编辑的行一开始是选中状态,结束编辑后仍然是选中状态
- var row = $('#materialData').datagrid('getChecked');
- if (endEditing()) {
- if (row.length == 0) {
- $.messager.alert('删除提示', '没有记录被选中!', 'info');
- return;
- }
- if (row.length > 0) {
- $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条单据信息吗?', function (r) {
- if (r) {
- for (var i = 0; i < row.length; i++) {
- $('#materialData').datagrid('deleteRow', $('#materialData').datagrid("getRowIndex", row[i]));
- }
- }
- });
- }
- }
-}
-function removeit(){
- if (editIndex == undefined) { return }
- $('#materialData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#materialData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData(type) {
- var change = $('#materialData').datagrid('getChanges').length;
- if(type =="add" && !change) {
- $.messager.alert('提示','请输入明细信息!','warning');
- return false;
- }
- var row = $('#materialData').datagrid('getRows');
- if(!row.length){
- $.messager.alert('提示',"请输入明细信息!",'info');
- return false;
- }
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if (row[i].DepotId == "" || row[i].MaterialId == "" || row[i].OperNumber == "" || row[i].UnitPrice === "" || row[i].AllPrice === "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-
-
-/**
- * 新增单据主表及单据子表
- * */
-function addDepotHeadAndDetail(url,infoStr){
- var inserted = null;
- if(pageType === "skip") {
- inserted = $("#materialData").datagrid('getChanges', "updated");
- } else {
- inserted = $("#materialData").datagrid('getChanges', "inserted");
- }
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated)
- }),
- success: function (tipInfo){
-
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
-
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
-
-
- });
-}
-/**
- * 修改单据主表及单据子表
- * */
-function updateDepotHeadAndDetail(url,infoStr,preTotalPrice){
- var inserted = $("#materialData").datagrid('getChanges', "inserted");
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- id:url.substring(url.lastIndexOf("?id=")+4,url.length),
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- preTotalPrice:preTotalPrice
- }),
- success: function (tipInfo){
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
- if (endEditing()) {
- $('#materialData').datagrid('acceptChanges');
- }
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-
-
-
diff --git a/erp_web/js/pages/materials/assemble_list.js b/erp_web/js/pages/materials/assemble_list.js
deleted file mode 100644
index 1e37bb85..00000000
--- a/erp_web/js/pages/materials/assemble_list.js
+++ /dev/null
@@ -1,2329 +0,0 @@
-//初始化界面
-var defDepotId = null;
-var kid = sessionStorage.getItem("userId");
-var pageType = getUrlParam('t'); //获取页面类型传值
-var depotList = null;
-var depotID = null;
-var supplierList = null;
-var supplierID = null;
-var personList = null;
-var personID = null;
-var ProjectSearch=null;
-var userBusinessList=null;
-var userdepot=null;
-var url;
-var depotHeadID = 0;
-var preTotalPrice = 0; //前一次加载的金额
-var orgDepotHead = "";
-var editIndex = undefined;
-/**默认编号有意义吗,不如空着吧*/
-var orgDefaultId=''; //单位默认编号
-var orgDefaultList; //存储查询出来的会员列表
-var accountList; //账户列表
-var outItemList; //支出项目列表
-var thisTaxRate = 0; //当前税率,选择供应商或者客户的时候设置
-var oldNumber = ""; //编辑前的单据编号
-var oldId = 0; //编辑前的单据Id
-var otherColumns = true; //明细中的‘别名’列是否显示
-var btnEnableList = getBtnStr(); //获取按钮的权限
-var mPropertyList = ""; //商品属性列表
-var defaultAccountId = 0; //默认账户id
-//改变宽度和高度
-$("#searchPanel").panel({width:webW-2});
-$("#tablePanel").panel({width:webW-2});
-var listTitle = "组装单列表"; //单据标题
-var depotString = "|"; //店铺id列表
-var listType = "其它"; //入库 出库
-var listSubType = "组装单"; //采购 销售等
-var payTypeTitle = "隐藏"; //付款 收款
-var organUrl = "/supplier/findBySelect_sup"; //组织数据接口地址
-var amountNum = "ZZD"; //单据编号开头字符
-$(function(){
- //初始化系统基础信息
- initSystemData_UB();
- initSelectInfo_UB();
- initSystemData_depot();
- initSelectInfo_depot();
- initSystemData_person();
- initSelectInfo_person();
- initSystemData_account();
- initSelectInfo_account();
- initSupplier(); //供应商
- initSalesman(); //销售人员
- initOutItemList(); //初始化支出项目
- initMProperty(); //初始化商品属性
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
-});
-
-//初始化系统基础信息
-function initSystemData_UB(){
- $.ajax({
- type:"get",
- url: "/userBusiness/getBasicData",
- data: ({
- KeyId:kid,
- Type:"UserDepot"
- }),
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if (res && res.code === 200) {
- userBusinessList = res.data.userBusinessList;
- }
- else {
- userBusinessList = null;
- }
- }
- });
-
-}
-//初始化页面选项卡
-function initSelectInfo_UB(){
-
- if(userBusinessList !=null)
- {
- if(userBusinessList.length>0)
- {
- //用户对应的仓库列表 [1][2][3]...
- userdepot =userBusinessList[0].value;
- }
- }
-}
-
-
-//初始化系统基础信息
-function initSystemData_depot(){
- $.ajax({
- type:"get",
- url: "/depot/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200){
- depotList = res.data;
- } else {
- $.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error');
- return;
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_depot(){
- var options = "";
-
- if(depotList !=null)
- {
- options = "";
- for(var i = 0 ;i < depotList.length;i++)
- {
- var depot = depotList[i];
-
- if(userdepot!=null)
- {
- if(userdepot.indexOf("["+depot.id+"]")!=-1)
- {
- if(depot.isDefault){
- defDepotId = depot.id;
- }
- options += '';
- depotString = depotString + depot.id + ",";
- }
- }
- if(depot.type === 1){
- depotString = depotString + depot.id + ",";
- }
- }
- depotString = depotString.substring(1, depotString.length-1);
- $("#ProjectId").empty().append(options);
- $("#AllocationProjectId").empty().append(options);
- $("#searchProjectId").empty().append('').append(options);
- }
-}
-
-//初始化供应商、客户、散户信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onLoadSuccess: function(res) {
- var data = $(this).combobox('getData');
- for(var i = 0; i<= data.length; i++){
- if(data && data[i] && data[i].supplier === "非会员"){
- orgDefaultId = data[i].id;
- }
- }
- },
- onSelect: function(rec){
- $.ajax({
- type:"get",
- url: "/supplier/findById",
- data: {
- supplierId: rec.id
- },
- dataType: "json",
- success: function (res){
- if(res && res.code === 200) {
- if(res.data && res.data[0]){
- thisTaxRate = res.data[0].taxRate; //设置当前的税率
- }
- }
- },
- error:function(){
-
- }
- });
- }
- });
-}
-
-//初始化销售人员
-function initSalesman(){
- $('#Salesman').combobox({
- url: "/person/getPersonByNumType?type=1",
- valueField:'id',
- textField:'name',
- multiple: true
- });
-}
-
-//初始化收入项目列表
-function initOutItemList(){
- $.ajax({
- type:"get",
- url: "/inOutItem/findBySelect?type=out",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res){
- if(res){
- outItemList = res;
- }
- },
- error:function(){
-
- }
- });
-}
-
-//初始化商品属性
-function initMProperty(){
- $.ajax({
- type: "get",
- url: "/materialProperty/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- name: ""
- }),
- currentPage: 1,
- pageSize: 100
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- var thisRows = res.data.page.rows;
- for (var i = 0; i < thisRows.length; i++) {
- if (thisRows[i].enabled) {
- mPropertyList += thisRows[i].nativename + ",";
- }
- }
- if (mPropertyList) {
- mPropertyList = mPropertyList.substring(0, mPropertyList.length - 1);
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化系统基础信息
-function initSystemData_person(){
- $.ajax({
- type:"get",
- url: "/person/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- personList = res.data.personList;
- }
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_person(){
- var options1 = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="仓管员")
- {
- options1 += '';
- }
- }
- $("#HandsPersonId").empty().append(options1);
- }
-}
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null){
- options = "";
- options += "";
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- if(account.isdefault) {
- defaultAccountId = account.id; //给账户赋值默认id
- }
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#depotHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- if(pageType === "skip") {
- var oldRowInfo = sessionStorage.getItem("rowInfo");
- editDepotHead(oldRowInfo); //自动弹出编辑框,带缓存数据
- }
- var hideType = undefined;
- var isHiddenStatus = true;
- if(payTypeTitle === "隐藏"){
- hideType = true; //隐藏当前列
- }
- var tableToolBar = [
- {
- id:'addDepotHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addDepotHead();
- }
- },
- {
- id:'deleteDepotHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteDepotHead();
- }
- }
- ];
- //如果允许的按钮列表中存在就显示,3-代表审核|反审核的权限
- if(btnEnableList && btnEnableList.indexOf(3)>-1){
- isHiddenStatus = false; //显示
- tableToolBar.push({
- id:'okDepotHead',
- text:'审核',
- iconCls:'icon-ok',
- handler:function() {
- setStatusFun();
- }
- },
- {
- id:'undoDepotHead',
- text:'反审核',
- iconCls:'icon-undo',
- handler:function() {
- setUnStatusFun();
- }
- });
- }
- else {
- isHiddenStatus = true; //隐藏
- }
- var isShowLastMoneyColumn = true; //是否显示优惠后金额和价税合计,true为隐藏,false为显示
- var isShowOrganNameColumn = true; //是否显示供应商、客户等信息,true为隐藏,false为显示
- var organNameTitle = ""; //组织名称标题
- var opWidth = 90; //操作宽度
- var opTitle = ""; //跳转按钮的标题
- $('#tableData').datagrid({
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: true,
- //交替出现背景
- striped : true,
- pageSize: 10,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:opWidth,
- formatter:function(value, rec,index) {
- var str = '';
- var orgId = rec.organid? rec.organid:0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
- { title: '单据编号',field: 'number',width:135, formatter:function (value,rec) {
- if(rec.linknumber) {
- return value + "[转]";
- } else {
- return value;
- }
- }
- },
- { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
- if(value) {
- return value.replace(",",",");
- }
- }
- },
- { title: '单据日期',field: 'opertimeStr',width:130},
- { title: '操作员',field: 'operpersonname',width:60},
- { title: '金额合计',field: 'totalprice',width:60},
- { title: '含税合计',field: 'totaltaxlastmoney',hidden:isShowLastMoneyColumn,width:60,formatter:function(value,rec){
- return (rec.discountmoney + rec.discountlastmoney).toFixed(2);
- }
- },
- { title: '优惠后金额',field: 'discountlastmoney',hidden:isShowLastMoneyColumn,width:80},
- { title: payTypeTitle,field: 'changeamount',width:50,hidden:hideType},
- { title: '状态',field: 'status',hidden:isHiddenStatus, width:70,align:"center",formatter:function(value){
- if(value === "0") {
- return "未审核";
- } else if(value === "1") {
- return "已审核";
- } else if(value === "2") {
- }
- }
- }
- ]],
- toolbar:tableToolBar,
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//查找库存的方法
-function findStockNumById(depotId, mId, monthTime, body, input, ratio, type){
- var thisRatio = 1; //比例
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (rec) {
- if(rec && rec.code === 200 && rec.data && rec.data[0]) {
- var loadRatio = 1; //在单位输入框上面加载比例字段
- if(rec.data[0].unit) { //如果存在计量单位信息
- loadRatio = 1;
- }
- else{
- var unitName = rec.data[0].unitName;
- if(unitName) {
- thisRatio = unitName.substring(unitName.indexOf(":")+1).replace(")","");
- unitName = unitName.substring(0, unitName.indexOf("("));
- }
- }
- //查询库存
- $.ajax({
- type: "get",
- url: '/depotItem/findStockNumById',
- data:{
- projectId: depotId,
- materialId: mId
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if (res.data && res.data.page && res.data.page[0]) {
- var thisStock = res.data.page[0].thisSum;
- if (type == "select") { //选择下拉框的时候
- if (ratio != undefined && ratio != 1) {
- loadRatio = ratio;
- }
- }
- else if (type == "click") { //点击库存的时候
- if (ratio != undefined) {
- loadRatio = ratio;
- }
- }
- thisStock = (thisStock / loadRatio).toFixed(2);
- body.find("[field='Stock']").find(input).val(thisStock).attr("data-stock", res.data.page[0].thisSum); //加载库存数据
- }
- else {
- body.find("[field='Stock']").find(input).val(0).attr("data-stock", 0); //加载库存数据
- }
- body.find("[field='Stock']").find(input).prop("readonly", "readonly"); //设置库存数据为只读
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
- }
- },
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- }
- });
-}
-//优惠率、合计的统计方法
-function statisticsFun(body,UnitPrice,OperNumber,footer,taxRate){
- var TotalPrice = 0;
- var taxLastMoneyTotal = 0;
- //金额的合计
- body.find("[field='AllPrice']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + UnitPrice*OperNumber;
- footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); //金额的合计
- //价税合计的总计
- body.find("[field='TaxLastMoney']").each(function(){
- if($(this).find("div").text()!==""){
- taxLastMoneyTotal = taxLastMoneyTotal + (parseFloat($(this).find("div").text().toString())-0);
- }
- });
- taxLastMoneyTotal = taxLastMoneyTotal + (UnitPrice*OperNumber*(1+taxRate/100));
- footer.find("[field='TaxLastMoney']").find("div").text((taxLastMoneyTotal).toFixed(2)); //价税合计的页脚总计
- var discount = $("#Discount").val(); //优惠率
- var discountMoney = (taxLastMoneyTotal*discount/100).toFixed(2);
- $("#DiscountMoney").val(discountMoney);//优惠金额
- var discountLastMoney = (taxLastMoneyTotal*(1-discount/100)).toFixed(2)
- $("#DiscountLastMoney").val(discountLastMoney);//优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
-
-}
-//初始化表格数据-商品列表-编辑状态
-function initTableData_material(type,TotalPrice){
- var body,footer,input; //定义表格和文本框
- var ratio = 1; //比例-品名专用
- var ratioDepot = 1; //比例-仓库用
- var monthTime = getNowFormatMonth();
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var depotHeadName = ""; //仓库名称
- var depotUrl = ""; //仓库接口地址
- var depotTextField = ""; //仓库下拉名称
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var anotherDepotUrl = ""; //对方仓库接口地址
- var anotherDepotTextField = "";
- depotHeadName = "仓库名称";
- depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- depotTextField = "depotName";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = false; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialData').datagrid({
- height:245,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: '商品类型',field: 'MType',editor:'validatebox',hidden:isShowMaterialTypeColumn,width:80},
- { title: depotHeadName, field: 'DepotId', editor: 'validatebox', width: 90,
- formatter: function (value, row, index) {
- return row.DepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: depotTextField,
- method: 'get',
- url: depotUrl,
- onSelect:function(rec){
- var depotId = rec.id;
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- if(mId){
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratioDepot, type);
- }
- }
- }
- }
- },
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialId',width:230,
- formatter:function(value,row,index){
- return row.MaterialName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'MaterialName',
- method:'get',
- url: "/material/findBySelect",
- panelWidth: 300, //下拉框的宽度
- //全面模糊匹配,过滤字段
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onBeforeLoad: function(param){
- param.mpList = mPropertyList; //商品属性
- },
- onSelect:function(rec){
- if(rec) {
- var mId = rec.Id;
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (res) {
- if(res && res.code === 200 && res.data && res.data[0]) {
- var retailPrice = res.data[0].retailprice-0; //零售价格
- var presetPriceOne = res.data[0].presetpriceone-0; //预计采购价
- var presetPriceTwo = res.data[0].presetpricetwo-0; //批发价
- var firstInUnit = res.data[0].firstinunit; //首选入库单位
- var firstOutUnit = res.data[0].firstoutunit; //首选出库单位
- var basicPresetPriceOne = ""; //多单位-入库-基础价格
- var basicPresetPriceTwo = ""; //多单位-出库-基础价格
- var retailPriceOne = ""; //多单位-入库-零售价格
- var otherPresetPriceOne = ""; //多单位-入库-其他价格
- var otherPresetPriceTwo = ""; //多单位-出库-其他价格
- var retailPriceTwo = ""; //多单位-出库-零售价格
- var basicUnit = ""; //基础单位
- var otherUnit = ""; //其他单位
- if(!res.data[0].unit){
- var ps = res.data[0].pricestrategy;
- var psObj = JSON.parse(ps);
- basicPresetPriceOne = psObj[0].basic.PresetPriceOne-0;
- basicPresetPriceTwo = psObj[0].basic.PresetPriceTwo-0;
- retailPriceOne = psObj[0].basic.RetailPrice-0;
- otherPresetPriceOne = psObj[1].other.PresetPriceOne-0;
- otherPresetPriceTwo = psObj[1].other.PresetPriceTwo-0;
- retailPriceTwo = psObj[1].other.RetailPrice-0;
- basicUnit = psObj[0].basic.Unit;
- otherUnit = psObj[1].other.Unit;
- }
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- if(res.data[0].unit){ //如果存在计量单位信息
- ratio = 1; //重置比例为1
- body.find("[field='Unit']").find(input).val(res.data[0].unit); //设置-计量单位信息
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- body.find("[field='Unit']").find(input).off("click"); //移除点击事件
- body.find("[field='Unit']").find(input).attr("data-ratio",ratio); //修改比例缓存信息
- }
- else {
- var unitName = res.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- var loadRatio = 1; //在单位输入框上面加载比例字段
- body.find("[field='Unit']").find(input).val(unitSetInput).attr("data-ratio", loadRatio); //设置-首选单位
-
- body.find("[field='Unit']").find(input).off("click").on("click",function(){
- if(basicUnit && otherUnit) {
- var self = this;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- " + basicUnit + "
";
- temp +="- " + otherUnit + "
";
- temp +="
";
- temp +="
";
- if($('.unit-list').length){
- $('.unit-list').remove(); //如果存在计量单位列表先移除
- }
- else {
- $(self).after(temp); //加载列表信息
- }
- //计量单位列表的单击事件
- $('.unit-list ul li').off("click").on("click",function(){
- var unit = $(this).text();
- var thisRatio = $(this).attr("data-ratio"); //获取比例
- $(self).val(unit).attr("data-ratio", thisRatio);
- $(self).keyup(); //模拟键盘操作
- $('.unit-list').remove(); //移除计量单位列表
- var stock = body.find("[field='Stock']").find(input).attr("data-stock"); //从缓存中取值
- var type = $(this).attr("data-type");
- var UnitPrice = 0;
- if(type === "basic"){
- body.find("[field='Stock']").find(input).val(stock); //修改库存
- }
- else if(type === "other"){
- body.find("[field='Stock']").find(input).val((stock/ratio).toFixed(2)); //修改库存
- }
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //获取数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击空白处移除计量单位列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.unit-list').remove(); //移除计量单位列表
- });
- }
- });
- }
- var detailPrice = 0; //明细列表-单价
- body.find("[field='OperNumber']").find(input).val(1); //数量初始化为1
- //单价和总价赋值
- if(!detailPrice) {
- detailPrice = 0;
- }
- body.find("[field='UnitPrice']").find(input).val(detailPrice);
- body.find("[field='AllPrice']").find(input).val(detailPrice);
- var taxRate = body.find("[field='TaxRate']").find(input).val()-0; //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((detailPrice*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,detailPrice,1,footer,taxRate);
-
- //查询库存信息
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- if(depotId) {
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, loadRatio, type);
- }
- }
- },
- error: function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- }
- });
- }
- }
- }
- }
- },
- { title: '库存',field: 'Stock',editor:'validatebox',width:70},
- { title: anotherDepotHeadName, field: 'AnotherDepotId',editor:'validatebox',hidden:isShowAnotherDepot,width:90,
- formatter: function (value, row, index) {
- return row.AnotherDepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: anotherDepotTextField,
- method: 'get',
- url: anotherDepotUrl
- }
- }
- },
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率(%)',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batchDel(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = 0;
- var TaxLastMoney = 0;
- var DiscountMoney = $("#DiscountMoney").val()-0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoney").val()-0; //优惠后金额
- if(type === "edit") {
- AllPrice = TotalPrice;
- TaxLastMoney = DiscountMoney + DiscountLastMoney;
- }
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": TaxLastMoney
- });
- data.footer = array;
- $("#materialData").datagrid('loadData',data);
- //如果是订单跳转到采购或销售
- if(pageType === "skip") {
- var skipList = $("#depotHeadFM .datagrid-body tr");
- //逐条自动点击每行数据
- skipList.each(function (i) {
- setTimeout(function () {
- skipList.eq(i).find("[field='Stock']").click();
- },(i+1)*1000);
- });
- }
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//初始化表格数据-商品列表-查看状态
-function initTableData_material_show(TotalPrice){
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var depotHeadName = ""; //仓库的列的标题
- depotHeadName = "仓库名称";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = false; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialDataShow').datagrid({
- height:245,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- onClickRow: onClickRow,
- columns:[[
- { title: '商品类型',field: 'MType',width:80, hidden:isShowMaterialTypeColumn},
- { title: depotHeadName,field: 'DepotName',editor:'validatebox',width:90},
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialName',width:230},
- { title: anotherDepotHeadName,field: 'AnotherDepotName',hidden:isShowAnotherDepot,width:90},
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validattebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = TotalPrice;
- var DiscountMoney = $("#DiscountMoneyShow").text() - 0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoneyShow").text() - 0; //优惠后金额
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": DiscountMoney + DiscountLastMoney
- });
- data.footer = array;
- $("#materialDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showDepotHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除单据信息
-function deleteDepotHead(depotHeadID, thisOrganId, totalPrice, status){
- if(status == "1" || status == "2") {
- $.messager.alert('删除提示','已审核和已转的单据不能删除!','warning');
- return;
- }
- $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
- if (r) {
- $.ajax({
- type:"post",
- // url: "/depotHead/" + depotHeadID + "/delete",
- url: "/depotHead/deleteDepotHeadAndDetail",
- dataType: "json",
- data:{
- id: depotHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-//订单转采购或销售
-function skipDepotHead(index, status){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- if(status == "0" || status == "2") {
- $.messager.alert('提示','未审核和已转的单据禁止操作!','warning');
- } else {
- sessionStorage.setItem("rowInfo", JSON.stringify(rowsdata)); //将单据信息存入缓存中
- }
-}
-
-//批量删除单据信息
-function batDeleteDepotHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条单据信息吗?',function(r)
- {
- if (r) {
- var ids = "";
- for (var i = 0; i < row.length; i++) {
- if (i == row.length - 1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- if (ids) {
- //批量删除
- $.ajax({
- type: "post",
- // url: "/depotHead/batchDelete",
- url: "/depotHead/batchDeleteDepotHeadAndDetail",
- dataType: "json",
- async: false,
- data: ({
- ids: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除单据信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('删除提示','没有能删除的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量审核
-function setStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('审核确认','确定要审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: "1",
- depotHeadIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('审核提示', '审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('审核提示','审核信息异常,请稍后再试!','error');
- return;
- }
- });
- } else {
- $.messager.alert('审核提示','没有能审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量反审核
-function setUnStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('反审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('反审核确认','确定要反审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type: "post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async: false,
- data: ({
- status: "0",
- depotHeadIDs: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('反审核提示', '反审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('反审核提示', '反审核信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('反审核提示','没有能反审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//生成单据编号
-function buildNumber() {
- $.ajax({
- type: "get",
- url: "/depotHead/buildNumber",
- success:function(res){
- if(res && res.code === 200){
- var obj = res.data;
- var defaultNumber = obj.DefaultNumber;
- var newNumber = amountNum + defaultNumber;
- $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
- }
- },
- error:function(){
- $.messager.alert('提示','生成单据编号失败!','error');
- }
- });
-}
-
-//新增信息
-function addDepotHead(){
- $('#depotHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- buildNumber(); //生成单据编号
- //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为0
- $("#Discount").val(0);
- $("#DiscountMoney").val(0);
- $("#DiscountLastMoney").val(0);
- $("#ChangeAmount").val(0);
- $("#Debt").val(0);
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- var addTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgDepotHead = "";
- depotHeadID = 0;
- initTableData_material("add"); //商品列表
- reject(); //撤销下、刷新商品列表
- $("#addOrgan").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加供应商信息');
- $('#supplierFM').form('clear');
- });
-
- $("#addMember").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加会员信息');
- $('#supplierFM').form('clear');
- });
- $("#addCustomer").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加客户信息');
- $('#supplierFM').form('clear');
- });
- url = '/depotHead/addDepotHeadAndDetail';
-
-}
-
-//编辑信息
-function editDepotHead(index, status){
- if(status == "1" || status == "2") {
- $.messager.alert('编辑提示','已审核和已转的单据不能编辑!','warning');
- return;
- }
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata ='';
- if(Number(index).toString()=='NaN'){
- rowsdata=$.parseJSON(index);
- }else{
- rowsdata=$("#tableData").datagrid("getRows")[index];
- }
- $("#ProjectId").focus().val(rowsdata.projectid);
- var ProjectId=rowsdata.projectid;
- if(ProjectId!='') {
- initSystemData_person(ProjectId);
- initSelectInfo_person();
- }
- var TotalPrice = rowsdata.totalprice; //合计金额
- if(pageType === "skip") { //从订单跳转过来
- buildNumber(); //生成单据编号
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- $("#LinkNumber").val(rowsdata.number); //关联订单号
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- $("#DiscountLastMoney").val(TotalPrice); //优惠后金额
- $("#ChangeAmount").val(TotalPrice).attr("data-changeamount", TotalPrice);
- } else {
- $("#Number").val(rowsdata.number).attr("data-defaultNumber",rowsdata.number);
- $("#OperTime").val(rowsdata.opertimeStr);
- $("#LinkNumber").val(rowsdata.linknumber==undefined?"":rowsdata.linknumber); //关联订单号
- $("#AccountId").val(rowsdata.accountid); //账户Id
- $("#DiscountLastMoney").val(rowsdata.discountlastmoney==undefined?"0.00":rowsdata.discountlastmoney); //优惠后金额
- $("#ChangeAmount").val(rowsdata.changeamount).attr("data-changeamount", rowsdata.changeamount);
- }
- $('#OrganId').combobox('setValue', rowsdata.organid==undefined?'':rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#Remark").val(rowsdata.remark);
- $("#Discount").val(rowsdata.discount==undefined?"0":rowsdata.discount);
- $("#DiscountMoney").val(rowsdata.discountmoney==undefined?"0.00":rowsdata.discountmoney);
- $("#Debt").val(Number((rowsdata.discountlastmoney==undefined?'0.00':rowsdata.discountlastmoney-rowsdata.changeamount)).toFixed(2));
- $("#AccountDay").val(rowsdata.accountday==undefined?"":rowsdata.accountday); //结算天数
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于扣预付款
- $("#AllocationProjectId").val(rowsdata.allocationprojectid);
- oldNumber = rowsdata.number; //记录编辑前的单据编号
- oldId = rowsdata.id; //记录单据Id
- var editTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- depotHeadID = rowsdata.id;
- //采购入库、销售出库的多账户加载
- if(rowsdata.accountidlist!=undefined && rowsdata.accountmoneylist!=undefined){
- $("#AccountId").val("many"); //下拉框选中多账户
- var accountArr = rowsdata.accountidlist.split(",");
- var accountMoneyArr = rowsdata.accountmoneylist.split(",");
- accountMoneyArr = changeListFmtPlus(accountMoneyArr) //将数组单个金额中的数值转为正数
-
- if(listSubType == "零售" || listSubType == "零售退货") {
- var manyAccountMoney = 0; //多账户合计-零售
- for (var j = 0; j < accountArr.length; j++) {
- if (accountList != null) {
- for (var i = 0; i < accountList.length; i++) {
- var account = accountList[i];
- if (accountArr[j] == account.id) {
- manyAccountMoney += accountMoneyArr[j] - 0; //多账户合计-零售
- }
- }
- }
- }
- $("#getAmount").val(manyAccountMoney); //收款金额、付款金额
- var changeAmount = $("#ChangeAmount").val()-0;
- $("#backAmount").val((manyAccountMoney-changeAmount).toFixed(2)); //找零
- }
-
- $("#AccountId").attr("data-accountArr", JSON.stringify(accountArr)).attr("data-accountMoneyArr", JSON.stringify(accountMoneyArr)); //json数据存储
- $(".many-account-ico").show(); //显示多账户的ico图标
- }
-
- //采购入库、销售出库的费用数据加载
- if(rowsdata.othermoneylist &&rowsdata.othermoneyitem){
- $("#OtherMoney").val(rowsdata.othermoney==undefined?"0":rowsdata.othermoney); //采购费用、销售费用
- var itemArr = rowsdata.othermoneylist.split(",");
- var itemMoneyArr = rowsdata.othermoneyitem.split(",");
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
-
- initTableData_material("edit",TotalPrice); //商品列表
- reject(); //撤销下、刷新商品列表
- if(pageType === "skip") {
- url = '/depotHead/addDepotHeadAndDetail'; //如果是从订单跳转过来,则此处为新增的接口
- //jshjshjsh
- $("#depotHeadFM .datagrid-body").find("[field='DepotId']").click();
- } else {
- url = '/depotHead/updateDepotHeadAndDetail?id=' + rowsdata.id; //更新接口
- }
-}
-
-//查看信息
-function showDepotHead(index){
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var manyAccountMoney = 0; //多账户合计-零售
- $("#ProjectIdShow").text(rowsdata.projectName);
- $("#NumberShow").text(rowsdata.number);
- $("#OperTimeShow").text(rowsdata.opertimeStr);
- $('#OrganIdShow').text(rowsdata.organName==undefined?'':rowsdata.organName);
- $("#HandsPersonIdShow").text(rowsdata.handsPersonName);
- if(rowsdata.accountName && rowsdata.accountName!=undefined){
- $("#AccountIdShow").text(rowsdata.accountName); //结算账户
- } else {
- var accountArr = (rowsdata.accountidlist==undefined?"":rowsdata.accountidlist).split(","); //账户id列表
- var accountMoneyArr =(rowsdata.accountmoneylist==undefined?"":rowsdata.accountmoneylist).split(","); //账户金额列表
- var accountIdShow = "";
- for(var j =0;j 查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- depotHeadID = rowsdata.id;
- initTableData_material_show(TotalPrice); //商品列表-查看状态
-}
-
-//绑定操作事件
-function bindEvent(){
- showDepotHeadDetails(1,initPageSize); //初始化时自动查询
- //搜索处理
- $("#searchBtn").off("click").on("click",function(){
- showDepotHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh',
- {
- pageNumber:1,
- pageSize:initPageSize
- });
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- //$("#searchProjectId").val("");
- $("#searchState").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //检查单据编号是否存在
- function checkDepotHeadNumber() {
- var thisNumber = $.trim($("#Number").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(thisNumber.length > 0 &&( oldNumber.length ==0 || thisNumber != oldNumber))
- {
- $.ajax({
- type:"get",
- url: "/depotHead/checkIsNumberExist",
- dataType: "json",
- async : false,
- data: ({
- DepotHeadID : oldId,
- Number : thisNumber
- }),
- success: function (tipInfo)
- {
- flag = tipInfo;
- if(tipInfo)
- {
- $.messager.alert('提示','抱歉,该单据编号已经存在','warning');
- return;
- }
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','检查单据编号是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
- //保存信息
- /**
- * 2019-01-25
- * 我对这个方法的实现结果存在严重怀疑,决定重构
- * 有如下疑点:
- * 1、保存完主表,返回结果后,再发起请求去操作子表,如何保证事务的一致性(业务数据一致性)
- * 2、保存完主表后,再通过selectmax的方式去获取主表主键id完全就是看人品的不可靠的思路
- * 修改计划:
- * 2019-01-25修改零售出库相关操作
- * 修改方式,重写url,将主从表操作合并
- *
- *
- * **/
- $("#saveDepotHead").off("click").on("click",function(){
- if(!$('#depotHeadFM').form('validate')){
- return;
- }
- else {
- //如果初始编号被修改了,就要判断单据编号是否存在
- if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
- //调用查询单据编号是否重名的方法
- if(checkDepotHeadNumber()){
- return;
- }
- }
- if (editIndex != undefined) {
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- //进行明细的校验
- if(depotHeadID ==0) {
- //新增模式下
- if (!CheckData("add")) {
- return;
- }
- }
- else {
- //编辑模式下
- if (!CheckData("edit")) {
- return;
- }
- }
- var OrganId = null, ProjectId = null,AllocationProjectId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val())-0;
- var TotalPrice = $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text();
- if($('#OrganId').length){
- OrganId = $('#OrganId').combobox('getValue');
- }
- var accountMoneyList = $("#AccountId").attr("data-accountmoneyarr"); //账户金额列表-多账户
- var accountMoneyArr;
- if(accountMoneyList) {
- accountMoneyList = accountMoneyList.replace("[","").replace("]","").toString();
- var reg=new RegExp("\"","g"); //创建正则RegExp对象
- accountMoneyList = accountMoneyList.replace(reg,""); //替换所有的双引号
- accountMoneyArr = accountMoneyList.split(","); //转为数组
- }
- //零售时候,可以从会员预付款中扣款
- var thisPayType = "现付";
- var SalesmanStr = "";
- var getAccountID = $.trim($("#AccountId").val());
- if($("#AccountId").val() === "many"){ //多账户
- getAccountID = null;
- }
- var infoStr=JSON.stringify({
- Type: listType,
- SubType: listSubType,
- ProjectId: ProjectId,
- AllocationProjectId: AllocationProjectId,
- DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
- Number: $.trim($("#Number").val()),
- LinkNumber: $.trim($("#LinkNumber").val()),
- OperTime: $("#OperTime").val(),
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Salesman: SalesmanStr, //销售人员
- AccountId: getAccountID,
- ChangeAmount: ChangeAmount, //付款/收款
- TotalPrice: TotalPrice, //合计
- PayType: thisPayType, //现付/预付款
- Remark: $.trim($("#Remark").val()),
- AccountIdList: $("#AccountId").attr("data-accountarr"), //账户列表-多账户
- AccountMoneyList: accountMoneyArr ? JSON.stringify(accountMoneyArr) : "", //账户金额列表-多账户
- Discount: $.trim($("#Discount").val()),
- DiscountMoney: $.trim($("#DiscountMoney").val()),
- DiscountLastMoney: $.trim($("#DiscountLastMoney").val()),
- OtherMoney: $.trim($("#OtherMoney").val()), //采购费用、销售费用
- OtherMoneyList: $("#OtherMoney").attr("data-itemarr"), //支出项目列表-涉及费用
- OtherMoneyItem: $("#OtherMoney").attr("data-itemmoneyarr"), //支出项目金额列表-涉及费用
- AccountDay: $("#AccountDay").val() //结算天数
- });
- /**
- * 零售出库,单独操作
- * */
- if(url.indexOf("/depotHead/addDepotHeadAndDetail")>=0){
- addDepotHeadAndDetail(url,infoStr);
- return;
- }else if(url.indexOf("/depotHead/updateDepotHeadAndDetail")>=0){
- updateDepotHeadAndDetail(url,infoStr,preTotalPrice);
- return;
- }
- }
- });
-
- //打印单据
- $("#printDepotHeadShow").off("click").on("click",function(){
- var tableString = $("#depotHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event){
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="State"||obj.id=="Number"))
- {
- $("#saveDepotHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber"||obj.id=="searchMaterial"))
- {
- $("#searchBtn").click();
- }
- });
-
- //优惠率输入框事件
- $("#Discount").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountNum = $(this).val();
- var discountMoney = (discountNum/100*totalPrice).toFixed(2);
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#DiscountMoney").val(discountMoney); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //优惠金额输入框事件
- $("#DiscountMoney").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountMoney = $(this).val();
- var discount = (discountMoney/totalPrice).toFixed(2)*100;
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#Discount").val(discount); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //付款、收款输入框事件
- $("#ChangeAmount").off("keyup").on("keyup",function(){
- var discountLastMoney = $("#DiscountLastMoney").val();
- var changeAmount = $(this).val();
- var debtMoney = (discountLastMoney - changeAmount).toFixed(2);
- $("#Debt").val(debtMoney); //本次欠款
- });
-
- //多账户结算窗口弹出事件
- function depotHeadAccountDlgFun(){
- $('#depotHeadAccountDlg').dialog('open').dialog('setTitle','
多账户结算');
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").remove(); //先移除输入栏目
- $("#accountMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#depotHeadAccountDlg .tabs-tmp .account-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#depotHeadAccountDlg .tabs-tmp tbody").html();
- var accountDlgHead = $("#depotHeadAccountDlg .account-head-tmp");
- accountDlgHead.after(contentTmp);
- }
-
- //获取账户信息
- function accountDlgFun() {
- var options = "";
- if(accountList !=null){
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- }
- $(".account-id-dlg").empty().append("").append(options);
- }
- }
- accountDlgFun(); //获取账户信息
- $("#depotHeadAccountDlg .tabs-tmp").hide(); //隐藏模板
-
- //账户金额输入框事件-多账户
- $("#depotHeadAccountDlg .account-dlg .account-money-dlg").off("keyup").on("keyup",function(){
- var totalAccoutNum = 0;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var eachAccountMoney = $(this).find(".account-money-dlg").val()-0;
- totalAccoutNum += eachAccountMoney;
- });
- $("#accountMoneyTotalDlg").text(totalAccoutNum);
- });
-
- //结算多账户列表的切换事件
- $("#depotHeadAccountDlg .account-dlg .account-id-dlg").off("change").on("change",function(){
- var selectAccount = $(this).children('option:selected').text();
- if(selectAccount === ""){
- var thisMoneyDom = $(this).closest(".account-content-tmp").find(".account-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text() - 0;
- $("#accountMoneyTotalDlg").text(accountMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //账户为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveDepotHeadAccountDlg").off("click").on("click", function(){
- //完成多账户的json数据存储
- var accountArr = []; //账户id数组
- var accountMoneyArr = []; //账户金额数组
- var errorIndex = -1;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var thisAccId = $(this).find(".account-id-dlg").val();
- var thisAccMoney = $(this).find(".account-money-dlg").val();
- if(!thisAccId && thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && !thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && thisAccMoney) {
- accountArr.push(thisAccId);
- accountMoneyArr.push(thisAccMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var discountLastMoneyNum =$("#DiscountLastMoney").val()-0; //优惠后金额
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text()-0; //本次付款或者收款
- if(accountMoneyTotal===0){
- $.messager.alert('错误提示',"请填写金额后保存",'warning');
- return;
- }
- if(accountArr.length && accountMoneyArr.length) {
- $("#AccountId").attr("data-accountArr",JSON.stringify(accountArr)).attr("data-accountMoneyArr",JSON.stringify(accountMoneyArr)); //json数据存储
- }
- $("#ChangeAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
- $("#Debt").val((discountLastMoneyNum-accountMoneyTotal).toFixed(2)); //本次欠款
- $("#depotHeadAccountDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#AccountId").attr("data-accountArr")){
- $("#depotHeadAccountDlg").dialog('close');
- }
- else {
- $("#depotHeadAccountDlg").dialog('close');
- $("#AccountId").val("").removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- }
- //多账户-取消按钮
- $("#cancelDepotHeadAccountDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //多账户-右上角的关闭按钮
- $("#depotHeadAccountDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
- }
- //点击多账户,弹出输入框
- $("#AccountId").off("change").on("change",function(){
- var selectText = $(this).children('option:selected').text();
- if(selectText === "多账户"){
- $("#ChangeAmount").prop("readonly","readonly");
- depotHeadAccountDlgFun();
- $(".many-account-ico").show(); //显示多账户小图标
- }
- else{
- $(this).removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- });
-
- //结算账户-多账户小图标-点击事件
- $(".many-account-ico").off("click").on("click",function(){
- depotHeadAccountDlgFun();
- //给弹窗赋值-多账户数据
- var accountArr = $("#AccountId").attr("data-accountArr");
- accountArr = JSON.parse(accountArr);
- var accountMoneyArr = $("#AccountId").attr("data-accountMoneyArr");
- accountMoneyArr = JSON.parse(accountMoneyArr);
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".account-id-dlg").val(accountArr[index]);
- $(this).find(".account-money-dlg").val(accountMoneyArr[index]);
- });
- $("#accountMoneyTotalDlg").text($("#ChangeAmount").val());
- });
-
- //点击采购费用、销售费用的事件
- $(".other-money-ico").off("click").on("click",function(){
- $('#otherMoneyDlg').dialog('open').dialog('setTitle','
'+ listSubType +'费用');
- $("#otherMoneyDlg .money-dlg .money-content-tmp").remove(); //先移除输入栏目
- $("#otherMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#otherMoneyDlg .tabs-tmp .money-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#otherMoneyDlg .tabs-tmp tbody").html();
- var moneyDlgHead = $("#otherMoneyDlg .money-head-tmp");
- moneyDlgHead.after(contentTmp);
- }
-
- //获取支出项目信息
- function moneyDlgFun() {
- var options = "";
- if(outItemList !=null){
- for(var i = 0 ;i < outItemList.length;i++) {
- var money = outItemList[i];
- options += '';
- }
- $(".money-id-dlg").empty().append("").append(options);
- }
- }
- moneyDlgFun(); //获取支出项目信息
- $("#otherMoneyDlg .tabs-tmp").hide(); //隐藏模板
-
- //支出项目的金额输入框事件
- $("#otherMoneyDlg .money-dlg .other-money-dlg").off("keyup").on("keyup",function(){
- var totalMoneyNum = 0;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var eachOtherMoney = $(this).find(".other-money-dlg").val()-0;
- totalMoneyNum += eachOtherMoney;
- });
- $("#otherMoneyTotalDlg").text(totalMoneyNum);
- });
-
- //支出项目列表的切换事件
- $("#otherMoneyDlg .money-dlg .money-id-dlg").off("change").on("change",function(){
- var selectItem = $(this).children('option:selected').text();
- if(selectItem === ""){
- var thisMoneyDom = $(this).closest(".money-content-tmp").find(".other-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text() - 0;
- $("#otherMoneyTotalDlg").text(otherMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //支出项目为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveOtherMoneyDlg").off("click").on("click", function(){
- //完成支出项目的json数据存储
- var itemArr = []; //支出项目id数组
- var itemMoneyArr = []; //支出项目金额数组
- var errorIndex = -1;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var thisId = $(this).find(".money-id-dlg").val();
- var thisMoney = $(this).find(".other-money-dlg").val();
- if(!thisId && thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && !thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && thisMoney) {
- itemArr.push(thisId);
- itemMoneyArr.push(thisMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text()-0; //合计金额
- if(otherMoneyTotal === 0){ //0的时候清空缓存数据
- $("#OtherMoney").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr");
- }
- if(itemArr.length && itemMoneyArr.length) {
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
- $("#OtherMoney").val(otherMoneyTotal); //给采购费用、销售费用赋值
- $("#otherMoneyDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#OtherMoney").attr("data-itemArr")){
- $("#otherMoneyDlg").dialog('close');
- }
- else {
- $("#otherMoneyDlg").dialog('close');
- $("#OtherMoney").val("").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr"); //将下拉置空并把缓存参数清空
- }
- }
- //费用-取消按钮
- $("#cancelOtherMoneyDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //费用-右上角的关闭按钮
- $("#otherMoneyDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
-
- //给弹窗赋值-采购费用、销售费用数据
- var itemArr = $("#OtherMoney").attr("data-itemArr");
- itemArr = JSON.parse(itemArr);
- var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr");
- itemMoneyArr = JSON.parse(itemMoneyArr);
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".money-id-dlg").val(itemArr[index]);
- if(itemMoneyArr[index]!="undefined"){
- $(this).find(".other-money-dlg").val(itemMoneyArr[index]);
- }
- });
- $("#otherMoneyTotalDlg").text($("#OtherMoney").val());
- });
-}
-
-function showDepotHeadDetails(pageNo,pageSize){
- var materialParam = $.trim($("#searchMaterial").val());
- var beginTime = $.trim($("#searchBeginTime").val());
- var endTime = $.trim($("#searchEndTime").val());
- if(beginTime) {
- beginTime = beginTime + ' 00:00:00';
- }
- if(endTime) {
- endTime = endTime + ' 23:59:59';
- }
- $.ajax({
- type: "get",
- url: "/depotHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- subType: listSubType,
- state: $.trim($("#searchState").val()),
- number: $.trim($("#searchNumber").val()),
- beginTime: beginTime,
- endTime: endTime,
- materialParam: materialParam,
- depotIds: depotString
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#depotHeadFM .datagrid-body");
- var footer =$("#depotHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
- //点击商品下拉框,自动加载数量、单价、金额
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //点击库存文本框,字段计算库存
- body.find("[field='Stock']").find(input).off("click").on("click",function(){
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- var monthTime = getNowFormatMonth();
- if(depotId && mId){
- var ratio = body.find("[field='Unit']").find(input).attr("data-ratio");
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //在新增的时候,这个ratio有值;在编辑的时候,这个ratio为undefined
- var type = "click"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratio, type);
- }
- else{
- body.find("[field='Stock']").find(input).val(0).attr("data-stock",0); //加载库存数据
- }
- });
- //修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计
- body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber =$(this).val()-0; //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
-
- });
- //修改单价,自动计算金额和合计
- body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice =$(this).val()-0; //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击单价,自动提示参考价格列表
- body.find("[field='UnitPrice']").find(input).off("click").on("click",function(){
- var self = this;
- var mValue = body.find("[field='MaterialId'] .combo-value").attr("value"); //获取选中的商品id
- if(!mValue) {
- return;
- }
- else {
- return;
- }
- });
- //修改含税单价,自动计算单价、金额、税额、价税合计和合计
- body.find("[field='TaxUnitPrice']").find(input).off("keyup").on("keyup",function(){
- var TaxUnitPrice =$(this).val()-0; //含税单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var UnitPrice = TaxUnitPrice/(1+taxRate/100); //计算单价
- body.find("[field='UnitPrice']").find(input).val((UnitPrice).toFixed(2)); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改金额,自动计算单价、税额、价税合计和合计
- body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var AllPrice =$(this).val()-0; //金额
- var UnitPrice = (AllPrice/OperNumber).toFixed(2);
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税率,自动计算含税单价、税额、价税合计和合计
- body.find("[field='TaxRate']").find(input).off("keyup").on("keyup",function(){
- var taxRate =$(this).val()-0; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税额,自动计算税率、含税单价、价税合计和合计
- body.find("[field='TaxMoney']").find(input).off("keyup").on("keyup",function(){
- var taxMoney =$(this).val()-0; //税额
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = taxMoney/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改价税合计,自动计算税率、含税单价、税额和合计
- body.find("[field='TaxLastMoney']").find(input).off("keyup").on("keyup",function(){
- var taxLastMoney =$(this).val()-0; //价税合计
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = (taxLastMoney-AllPrice)/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
-
- //加载税率
- if(thisTaxRate) {
- body.find("[field='TaxRate']").find(input).val(thisTaxRate);
- }
- else {
- body.find("[field='TaxRate']").find(input).val(0); //默认为0
- }
-
- //在商品类型加载 组装件、普通子件
- var mType = body.find("[field='MType']");
- var rowListLength = mType.find(input).closest(".datagrid-row").attr("datagrid-row-index");
- var mTypeValue = "组合件";
- if(rowListLength > 0){
- mTypeValue = "普通子件";
- }
- mType.find(input).val(mTypeValue).prop("readonly","readonly");
- },500);
-}
-
-//结束编辑
-function endEditing() {
- if (editIndex == undefined) { return true }
- if ($('#materialData').datagrid('validateRow', editIndex)) {
- //仓库信息
- var edDepot = $('#materialData').datagrid('getEditor', {index:editIndex,field:'DepotId'});
- var DepotName = $(edDepot.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName;
- //商品信息
- var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'});
- var MaterialName = $(edMaterial.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName;
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#materialData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append(){
- if (endEditing()) {
- $('#materialData').datagrid('appendRow', {DepotId:defDepotId});
- editIndex = $('#materialData').datagrid('getRows').length - 1;
- $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function batchDel(){
- /**
- * 重写一下删除的逻辑
- * 获取所有选中行,直接从列表中移除
- * 点击保存时,将需要后台删除的数据提交到服务器
- * **/
- /**
- * create by: qiankunpingtai
- * create time: 2019/3/20 16:26
- * description:
- * 这个地方比较坑的,花了一个多小时才搞明白为什么
- * 1、删除之前必须先调用endEditing结束编辑
- * 2、如果只是调用endEditing结束编辑那么正在编辑行的被选中状态会被去掉
- * 所以要在调用endEditing先获取选中的行
- */
- //如果编辑的行一开始是选中状态,结束编辑后仍然是选中状态
- var row = $('#materialData').datagrid('getChecked');
- if (endEditing()) {
- if (row.length == 0) {
- $.messager.alert('删除提示', '没有记录被选中!', 'info');
- return;
- }
- if (row.length > 0) {
- $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条单据信息吗?', function (r) {
- if (r) {
- for (var i = 0; i < row.length; i++) {
- $('#materialData').datagrid('deleteRow', $('#materialData').datagrid("getRowIndex", row[i]));
- }
- }
- });
- }
- }
-}
-function removeit(){
- if (editIndex == undefined) { return }
- $('#materialData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#materialData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData(type) {
- var change = $('#materialData').datagrid('getChanges').length;
- if(type =="add" && !change) {
- $.messager.alert('提示','请输入明细信息!','warning');
- return false;
- }
- var row = $('#materialData').datagrid('getRows');
- if(!row.length){
- $.messager.alert('提示',"请输入明细信息!",'info');
- return false;
- }
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if (row[i].DepotId == "" || row[i].MaterialId == "" || row[i].OperNumber == "" || row[i].UnitPrice === "" || row[i].AllPrice === "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-
-/**
- * 新增单据主表及单据子表
- * */
-function addDepotHeadAndDetail(url,infoStr){
- var inserted = null;
- if(pageType === "skip") {
- inserted = $("#materialData").datagrid('getChanges', "updated");
- } else {
- inserted = $("#materialData").datagrid('getChanges', "inserted");
- }
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated)
- }),
- success: function (tipInfo){
-
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
-
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
-
-
- });
-}
-/**
- * 修改单据主表及单据子表
- * */
-function updateDepotHeadAndDetail(url,infoStr,preTotalPrice){
- var inserted = $("#materialData").datagrid('getChanges', "inserted");
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- id:url.substring(url.lastIndexOf("?id=")+4,url.length),
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- preTotalPrice:preTotalPrice
- }),
- success: function (tipInfo){
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
- if (endEditing()) {
- $('#materialData').datagrid('acceptChanges');
- }
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-
-
-
diff --git a/erp_web/js/pages/materials/disassemble_list.js b/erp_web/js/pages/materials/disassemble_list.js
deleted file mode 100644
index cd6e9e03..00000000
--- a/erp_web/js/pages/materials/disassemble_list.js
+++ /dev/null
@@ -1,2332 +0,0 @@
-//初始化界面
-var defDepotId = null;
-var kid = sessionStorage.getItem("userId");
-var pageType = getUrlParam('t'); //获取页面类型传值
-var depotList = null;
-var depotID = null;
-var supplierList = null;
-var supplierID = null;
-var personList = null;
-var personID = null;
-var ProjectSearch=null;
-var userBusinessList=null;
-var userdepot=null;
-var url;
-var depotHeadID = 0;
-var preTotalPrice = 0; //前一次加载的金额
-var orgDepotHead = "";
-var editIndex = undefined;
-/**默认编号有意义吗,不如空着吧*/
-var orgDefaultId=''; //单位默认编号
-var orgDefaultList; //存储查询出来的会员列表
-var accountList; //账户列表
-var outItemList; //支出项目列表
-var thisTaxRate = 0; //当前税率,选择供应商或者客户的时候设置
-var oldNumber = ""; //编辑前的单据编号
-var oldId = 0; //编辑前的单据Id
-var otherColumns = true; //明细中的‘别名’列是否显示
-var btnEnableList = getBtnStr(); //获取按钮的权限
-var mPropertyList = ""; //商品属性列表
-var defaultAccountId = 0; //默认账户id
-//改变宽度和高度
-$("#searchPanel").panel({width:webW-2});
-$("#tablePanel").panel({width:webW-2});
-var listTitle = "拆卸单列表"; //单据标题
-var depotString = "|"; //店铺id列表
-var listType = "其它"; //入库 出库
-var listSubType = "拆卸单"; //采购 销售等
-var payTypeTitle = "隐藏"; //付款 收款
-var organUrl = "/supplier/findBySelect_sup"; //组织数据接口地址
-var amountNum = "CXD"; //单据编号开头字符
-$(function(){
- //初始化系统基础信息
- initSystemData_UB();
- initSelectInfo_UB();
- initSystemData_depot();
- initSelectInfo_depot();
- initSystemData_person();
- initSelectInfo_person();
- initSystemData_account();
- initSelectInfo_account();
- initSupplier(); //供应商
- initSalesman(); //销售人员
- initOutItemList(); //初始化支出项目
- initMProperty(); //初始化商品属性
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
-});
-//初始化系统基础信息
-function initSystemData_UB(){
- $.ajax({
- type:"get",
- url: "/userBusiness/getBasicData",
- data: ({
- KeyId:kid,
- Type:"UserDepot"
- }),
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if (res && res.code === 200) {
- userBusinessList = res.data.userBusinessList;
- }
- else {
- userBusinessList = null;
- }
- }
- });
-
-}
-//初始化页面选项卡
-function initSelectInfo_UB(){
-
- if(userBusinessList !=null)
- {
- if(userBusinessList.length>0)
- {
- //用户对应的仓库列表 [1][2][3]...
- userdepot =userBusinessList[0].value;
- }
- }
-}
-
-
-//初始化系统基础信息
-function initSystemData_depot(){
- $.ajax({
- type:"get",
- url: "/depot/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200){
- depotList = res.data;
- } else {
- $.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error');
- return;
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_depot(){
- var options = "";
-
- if(depotList !=null)
- {
- options = "";
- for(var i = 0 ;i < depotList.length;i++)
- {
- var depot = depotList[i];
-
- if(userdepot!=null)
- {
- if(userdepot.indexOf("["+depot.id+"]")!=-1)
- {
- if(depot.isDefault){
- defDepotId = depot.id;
- }
- options += '';
- depotString = depotString + depot.id + ",";
- }
- }
- if(depot.type === 1){
- depotString = depotString + depot.id + ",";
- }
- }
- depotString = depotString.substring(1, depotString.length-1);
- $("#ProjectId").empty().append(options);
- $("#AllocationProjectId").empty().append(options);
- $("#searchProjectId").empty().append('').append(options);
- }
-}
-
-//初始化供应商、客户、散户信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onLoadSuccess: function(res) {
- var data = $(this).combobox('getData');
- for(var i = 0; i<= data.length; i++){
- if(data && data[i] && data[i].supplier === "非会员"){
- orgDefaultId = data[i].id;
- }
- }
- },
- onSelect: function(rec){
- $.ajax({
- type:"get",
- url: "/supplier/findById",
- data: {
- supplierId: rec.id
- },
- dataType: "json",
- success: function (res){
- if(res && res.code === 200) {
- if(res.data && res.data[0]){
- thisTaxRate = res.data[0].taxRate; //设置当前的税率
- }
- }
- },
- error:function(){
-
- }
- });
- }
- });
-}
-
-//初始化销售人员
-function initSalesman(){
- $('#Salesman').combobox({
- url: "/person/getPersonByNumType?type=1",
- valueField:'id',
- textField:'name',
- multiple: true
- });
-}
-
-//初始化收入项目列表
-function initOutItemList(){
- $.ajax({
- type:"get",
- url: "/inOutItem/findBySelect?type=out",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res){
- if(res){
- outItemList = res;
- }
- },
- error:function(){
-
- }
- });
-}
-
-//初始化商品属性
-function initMProperty(){
- $.ajax({
- type: "get",
- url: "/materialProperty/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- name: ""
- }),
- currentPage: 1,
- pageSize: 100
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- var thisRows = res.data.page.rows;
- for (var i = 0; i < thisRows.length; i++) {
- if (thisRows[i].enabled) {
- mPropertyList += thisRows[i].nativename + ",";
- }
- }
- if (mPropertyList) {
- mPropertyList = mPropertyList.substring(0, mPropertyList.length - 1);
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化系统基础信息
-function initSystemData_person(){
- $.ajax({
- type:"get",
- url: "/person/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- personList = res.data.personList;
- }
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_person(){
- var options1 = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="仓管员")
- {
- options1 += '';
- }
- }
- $("#HandsPersonId").empty().append(options1);
- }
-}
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null){
- options = "";
- options += "";
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- if(account.isdefault) {
- defaultAccountId = account.id; //给账户赋值默认id
- }
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#depotHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- if(pageType === "skip") {
- var oldRowInfo = sessionStorage.getItem("rowInfo");
- editDepotHead(oldRowInfo); //自动弹出编辑框,带缓存数据
- }
- var hideType = undefined;
- var isHiddenStatus = true;
- if(payTypeTitle === "隐藏"){
- hideType = true; //隐藏当前列
- }
- var tableToolBar = [
- {
- id:'addDepotHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addDepotHead();
- }
- },
- {
- id:'deleteDepotHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteDepotHead();
- }
- }
- ];
- //如果允许的按钮列表中存在就显示,3-代表审核|反审核的权限
- if(btnEnableList && btnEnableList.indexOf(3)>-1){
- isHiddenStatus = false; //显示
- tableToolBar.push({
- id:'okDepotHead',
- text:'审核',
- iconCls:'icon-ok',
- handler:function() {
- setStatusFun();
- }
- },
- {
- id:'undoDepotHead',
- text:'反审核',
- iconCls:'icon-undo',
- handler:function() {
- setUnStatusFun();
- }
- });
- }
- else {
- isHiddenStatus = true; //隐藏
- }
- var isShowLastMoneyColumn = true; //是否显示优惠后金额和价税合计,true为隐藏,false为显示
- var isShowOrganNameColumn = true; //是否显示供应商、客户等信息,true为隐藏,false为显示
- var organNameTitle = ""; //组织名称标题
- var opWidth = 90; //操作宽度
- var opTitle = ""; //跳转按钮的标题
- $('#tableData').datagrid({
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: true,
- //交替出现背景
- striped : true,
- pageSize: 10,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:opWidth,
- formatter:function(value, rec,index) {
- var str = '';
- var orgId = rec.organid? rec.organid:0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
- { title: '单据编号',field: 'number',width:135, formatter:function (value,rec) {
- if(rec.linknumber) {
- return value + "[转]";
- } else {
- return value;
- }
- }
- },
- { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
- if(value) {
- return value.replace(",",",");
- }
- }
- },
- { title: '单据日期',field: 'opertimeStr',width:130},
- { title: '操作员',field: 'operpersonname',width:60},
- { title: '金额合计',field: 'totalprice',width:60},
- { title: '含税合计',field: 'totaltaxlastmoney',hidden:isShowLastMoneyColumn,width:60,formatter:function(value,rec){
- return (rec.discountmoney + rec.discountlastmoney).toFixed(2);
- }
- },
- { title: '优惠后金额',field: 'discountlastmoney',hidden:isShowLastMoneyColumn,width:80},
- { title: payTypeTitle,field: 'changeamount',width:50,hidden:hideType},
- { title: '状态',field: 'status',hidden:isHiddenStatus, width:70,align:"center",formatter:function(value){
- if(value === "0") {
- return "未审核";
- } else if(value === "1") {
- return "已审核";
- } else if(value === "2") {
- }
- }
- }
- ]],
- toolbar:tableToolBar,
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//查找库存的方法
-function findStockNumById(depotId, mId, monthTime, body, input, ratio, type){
- var thisRatio = 1; //比例
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (rec) {
- if(rec && rec.code === 200 && rec.data && rec.data[0]) {
- var loadRatio = 1; //在单位输入框上面加载比例字段
- if(rec.data[0].unit) { //如果存在计量单位信息
- loadRatio = 1;
- }
- else{
- var unitName = rec.data[0].unitName;
- if(unitName) {
- thisRatio = unitName.substring(unitName.indexOf(":")+1).replace(")","");
- unitName = unitName.substring(0, unitName.indexOf("("));
- }
- }
- //查询库存
- $.ajax({
- type: "get",
- url: '/depotItem/findStockNumById',
- data:{
- projectId: depotId,
- materialId: mId
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if (res.data && res.data.page && res.data.page[0]) {
- var thisStock = res.data.page[0].thisSum;
- if (type == "select") { //选择下拉框的时候
- if (ratio != undefined && ratio != 1) {
- loadRatio = ratio;
- }
- }
- else if (type == "click") { //点击库存的时候
- if (ratio != undefined) {
- loadRatio = ratio;
- }
- }
- thisStock = (thisStock / loadRatio).toFixed(2);
- body.find("[field='Stock']").find(input).val(thisStock).attr("data-stock", res.data.page[0].thisSum); //加载库存数据
- }
- else {
- body.find("[field='Stock']").find(input).val(0).attr("data-stock", 0); //加载库存数据
- }
- body.find("[field='Stock']").find(input).prop("readonly", "readonly"); //设置库存数据为只读
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
- }
- },
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- }
- });
-}
-//优惠率、合计的统计方法
-function statisticsFun(body,UnitPrice,OperNumber,footer,taxRate){
- var TotalPrice = 0;
- var taxLastMoneyTotal = 0;
- //金额的合计
- body.find("[field='AllPrice']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + UnitPrice*OperNumber;
- footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); //金额的合计
- //价税合计的总计
- body.find("[field='TaxLastMoney']").each(function(){
- if($(this).find("div").text()!==""){
- taxLastMoneyTotal = taxLastMoneyTotal + (parseFloat($(this).find("div").text().toString())-0);
- }
- });
- taxLastMoneyTotal = taxLastMoneyTotal + (UnitPrice*OperNumber*(1+taxRate/100));
- footer.find("[field='TaxLastMoney']").find("div").text((taxLastMoneyTotal).toFixed(2)); //价税合计的页脚总计
- var discount = $("#Discount").val(); //优惠率
- var discountMoney = (taxLastMoneyTotal*discount/100).toFixed(2);
- $("#DiscountMoney").val(discountMoney);//优惠金额
- var discountLastMoney = (taxLastMoneyTotal*(1-discount/100)).toFixed(2)
- $("#DiscountLastMoney").val(discountLastMoney);//优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
-
-}
-//初始化表格数据-商品列表-编辑状态
-function initTableData_material(type,TotalPrice){
- var body,footer,input; //定义表格和文本框
- var ratio = 1; //比例-品名专用
- var ratioDepot = 1; //比例-仓库用
- var monthTime = getNowFormatMonth();
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var depotHeadName = ""; //仓库名称
- var depotUrl = ""; //仓库接口地址
- var depotTextField = ""; //仓库下拉名称
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var anotherDepotUrl = ""; //对方仓库接口地址
- var anotherDepotTextField = "";
- depotHeadName = "仓库名称";
- depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- depotTextField = "depotName";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = false; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialData').datagrid({
- height:245,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: '商品类型',field: 'MType',editor:'validatebox',hidden:isShowMaterialTypeColumn,width:80},
- { title: depotHeadName, field: 'DepotId', editor: 'validatebox', width: 90,
- formatter: function (value, row, index) {
- return row.DepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: depotTextField,
- method: 'get',
- url: depotUrl,
- onSelect:function(rec){
- var depotId = rec.id;
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- if(mId){
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratioDepot, type);
- }
- }
- }
- }
- },
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialId',width:230,
- formatter:function(value,row,index){
- return row.MaterialName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'MaterialName',
- method:'get',
- url: "/material/findBySelect",
- panelWidth: 300, //下拉框的宽度
- //全面模糊匹配,过滤字段
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onBeforeLoad: function(param){
- param.mpList = mPropertyList; //商品属性
- },
- onSelect:function(rec){
- if(rec) {
- var mId = rec.Id;
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (res) {
- if(res && res.code === 200 && res.data && res.data[0]) {
- var retailPrice = res.data[0].retailprice-0; //零售价格
- var presetPriceOne = res.data[0].presetpriceone-0; //预计采购价
- var presetPriceTwo = res.data[0].presetpricetwo-0; //批发价
- var firstInUnit = res.data[0].firstinunit; //首选入库单位
- var firstOutUnit = res.data[0].firstoutunit; //首选出库单位
- var basicPresetPriceOne = ""; //多单位-入库-基础价格
- var basicPresetPriceTwo = ""; //多单位-出库-基础价格
- var retailPriceOne = ""; //多单位-入库-零售价格
- var otherPresetPriceOne = ""; //多单位-入库-其他价格
- var otherPresetPriceTwo = ""; //多单位-出库-其他价格
- var retailPriceTwo = ""; //多单位-出库-零售价格
- var basicUnit = ""; //基础单位
- var otherUnit = ""; //其他单位
- if(!res.data[0].unit){
- var ps = res.data[0].pricestrategy;
- var psObj = JSON.parse(ps);
- basicPresetPriceOne = psObj[0].basic.PresetPriceOne-0;
- basicPresetPriceTwo = psObj[0].basic.PresetPriceTwo-0;
- retailPriceOne = psObj[0].basic.RetailPrice-0;
- otherPresetPriceOne = psObj[1].other.PresetPriceOne-0;
- otherPresetPriceTwo = psObj[1].other.PresetPriceTwo-0;
- retailPriceTwo = psObj[1].other.RetailPrice-0;
- basicUnit = psObj[0].basic.Unit;
- otherUnit = psObj[1].other.Unit;
- }
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- if(res.data[0].unit){ //如果存在计量单位信息
- ratio = 1; //重置比例为1
- body.find("[field='Unit']").find(input).val(res.data[0].unit); //设置-计量单位信息
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- body.find("[field='Unit']").find(input).off("click"); //移除点击事件
- body.find("[field='Unit']").find(input).attr("data-ratio",ratio); //修改比例缓存信息
- }
- else {
- var unitName = res.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- var loadRatio = 1; //在单位输入框上面加载比例字段
- body.find("[field='Unit']").find(input).val(unitSetInput).attr("data-ratio", loadRatio); //设置-首选单位
-
- body.find("[field='Unit']").find(input).off("click").on("click",function(){
- if(basicUnit && otherUnit) {
- var self = this;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- " + basicUnit + "
";
- temp +="- " + otherUnit + "
";
- temp +="
";
- temp +="
";
- if($('.unit-list').length){
- $('.unit-list').remove(); //如果存在计量单位列表先移除
- }
- else {
- $(self).after(temp); //加载列表信息
- }
- //计量单位列表的单击事件
- $('.unit-list ul li').off("click").on("click",function(){
- var unit = $(this).text();
- var thisRatio = $(this).attr("data-ratio"); //获取比例
- $(self).val(unit).attr("data-ratio", thisRatio);
- $(self).keyup(); //模拟键盘操作
- $('.unit-list').remove(); //移除计量单位列表
- var stock = body.find("[field='Stock']").find(input).attr("data-stock"); //从缓存中取值
- var type = $(this).attr("data-type");
- var UnitPrice = 0;
- if(type === "basic"){
- body.find("[field='Stock']").find(input).val(stock); //修改库存
- }
- else if(type === "other"){
- body.find("[field='Stock']").find(input).val((stock/ratio).toFixed(2)); //修改库存
- }
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //获取数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击空白处移除计量单位列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.unit-list').remove(); //移除计量单位列表
- });
- }
- });
- }
- var detailPrice = 0; //明细列表-单价
- body.find("[field='OperNumber']").find(input).val(1); //数量初始化为1
- //单价和总价赋值
- if(!detailPrice) {
- detailPrice = 0;
- }
- body.find("[field='UnitPrice']").find(input).val(detailPrice);
- body.find("[field='AllPrice']").find(input).val(detailPrice);
- var taxRate = body.find("[field='TaxRate']").find(input).val()-0; //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((detailPrice*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,detailPrice,1,footer,taxRate);
-
- //查询库存信息
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- if(depotId) {
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, loadRatio, type);
- }
- }
- },
- error: function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- }
- });
- }
- }
- }
- }
- },
- { title: '库存',field: 'Stock',editor:'validatebox',width:70},
- { title: anotherDepotHeadName, field: 'AnotherDepotId',editor:'validatebox',hidden:isShowAnotherDepot,width:90,
- formatter: function (value, row, index) {
- return row.AnotherDepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: anotherDepotTextField,
- method: 'get',
- url: anotherDepotUrl
- }
- }
- },
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率(%)',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batchDel(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = 0;
- var TaxLastMoney = 0;
- var DiscountMoney = $("#DiscountMoney").val()-0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoney").val()-0; //优惠后金额
- if(type === "edit") {
- AllPrice = TotalPrice;
- TaxLastMoney = DiscountMoney + DiscountLastMoney;
- }
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": TaxLastMoney
- });
- data.footer = array;
- $("#materialData").datagrid('loadData',data);
- //如果是订单跳转到采购或销售
- if(pageType === "skip") {
- var skipList = $("#depotHeadFM .datagrid-body tr");
- //逐条自动点击每行数据
- skipList.each(function (i) {
- setTimeout(function () {
- skipList.eq(i).find("[field='Stock']").click();
- },(i+1)*1000);
- });
- }
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//初始化表格数据-商品列表-查看状态
-function initTableData_material_show(TotalPrice){
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var depotHeadName = ""; //仓库的列的标题
- if(listSubType == "调拨"){
- isShowAnotherDepot = false; //调拨时候显示对方仓库
- anotherDepotHeadName = "调入仓库";
- }
- depotHeadName = "仓库名称";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = false; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialDataShow').datagrid({
- height:245,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- onClickRow: onClickRow,
- columns:[[
- { title: '商品类型',field: 'MType',width:80, hidden:isShowMaterialTypeColumn},
- { title: depotHeadName,field: 'DepotName',editor:'validatebox',width:90},
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialName',width:230},
- { title: anotherDepotHeadName,field: 'AnotherDepotName',hidden:isShowAnotherDepot,width:90},
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validattebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = TotalPrice;
- var DiscountMoney = $("#DiscountMoneyShow").text() - 0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoneyShow").text() - 0; //优惠后金额
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": DiscountMoney + DiscountLastMoney
- });
- data.footer = array;
- $("#materialDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showDepotHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除单据信息
-function deleteDepotHead(depotHeadID, thisOrganId, totalPrice, status){
- if(status == "1" || status == "2") {
- $.messager.alert('删除提示','已审核和已转的单据不能删除!','warning');
- return;
- }
- $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
- if (r) {
- $.ajax({
- type:"post",
- // url: "/depotHead/" + depotHeadID + "/delete",
- url: "/depotHead/deleteDepotHeadAndDetail",
- dataType: "json",
- data:{
- id: depotHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-//订单转采购或销售
-function skipDepotHead(index, status){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- if(status == "0" || status == "2") {
- $.messager.alert('提示','未审核和已转的单据禁止操作!','warning');
- } else {
- sessionStorage.setItem("rowInfo", JSON.stringify(rowsdata)); //将单据信息存入缓存中
- }
-}
-
-//批量删除单据信息
-function batDeleteDepotHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条单据信息吗?',function(r)
- {
- if (r) {
- var ids = "";
- for (var i = 0; i < row.length; i++) {
- if (i == row.length - 1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- if (ids) {
- //批量删除
- $.ajax({
- type: "post",
- // url: "/depotHead/batchDelete",
- url: "/depotHead/batchDeleteDepotHeadAndDetail",
- dataType: "json",
- async: false,
- data: ({
- ids: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除单据信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('删除提示','没有能删除的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量审核
-function setStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('审核确认','确定要审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: "1",
- depotHeadIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('审核提示', '审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('审核提示','审核信息异常,请稍后再试!','error');
- return;
- }
- });
- } else {
- $.messager.alert('审核提示','没有能审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量反审核
-function setUnStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('反审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('反审核确认','确定要反审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type: "post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async: false,
- data: ({
- status: "0",
- depotHeadIDs: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('反审核提示', '反审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('反审核提示', '反审核信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('反审核提示','没有能反审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//生成单据编号
-function buildNumber() {
- $.ajax({
- type: "get",
- url: "/depotHead/buildNumber",
- success:function(res){
- if(res && res.code === 200){
- var obj = res.data;
- var defaultNumber = obj.DefaultNumber;
- var newNumber = amountNum + defaultNumber;
- $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
- }
- },
- error:function(){
- $.messager.alert('提示','生成单据编号失败!','error');
- }
- });
-}
-
-//新增信息
-function addDepotHead(){
- $('#depotHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- buildNumber(); //生成单据编号
- //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为0
- $("#Discount").val(0);
- $("#DiscountMoney").val(0);
- $("#DiscountLastMoney").val(0);
- $("#ChangeAmount").val(0);
- $("#Debt").val(0);
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- var addTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgDepotHead = "";
- depotHeadID = 0;
- initTableData_material("add"); //商品列表
- reject(); //撤销下、刷新商品列表
- $("#addOrgan").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加供应商信息');
- $('#supplierFM').form('clear');
- });
-
- $("#addMember").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加会员信息');
- $('#supplierFM').form('clear');
- });
- $("#addCustomer").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加客户信息');
- $('#supplierFM').form('clear');
- });
- url = '/depotHead/addDepotHeadAndDetail';
-}
-
-//编辑信息
-function editDepotHead(index, status){
- if(status == "1" || status == "2") {
- $.messager.alert('编辑提示','已审核和已转的单据不能编辑!','warning');
- return;
- }
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata ='';
- if(Number(index).toString()=='NaN'){
- rowsdata=$.parseJSON(index);
- }else{
- rowsdata=$("#tableData").datagrid("getRows")[index];
- }
- $("#ProjectId").focus().val(rowsdata.projectid);
- var ProjectId=rowsdata.projectid;
- if(ProjectId!='') {
- initSystemData_person(ProjectId);
- initSelectInfo_person();
- }
- var TotalPrice = rowsdata.totalprice; //合计金额
- if(pageType === "skip") { //从订单跳转过来
- buildNumber(); //生成单据编号
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- $("#LinkNumber").val(rowsdata.number); //关联订单号
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- $("#DiscountLastMoney").val(TotalPrice); //优惠后金额
- $("#ChangeAmount").val(TotalPrice).attr("data-changeamount", TotalPrice);
- } else {
- $("#Number").val(rowsdata.number).attr("data-defaultNumber",rowsdata.number);
- $("#OperTime").val(rowsdata.opertimeStr);
- $("#LinkNumber").val(rowsdata.linknumber==undefined?"":rowsdata.linknumber); //关联订单号
- $("#AccountId").val(rowsdata.accountid); //账户Id
- $("#DiscountLastMoney").val(rowsdata.discountlastmoney==undefined?"0.00":rowsdata.discountlastmoney); //优惠后金额
- $("#ChangeAmount").val(rowsdata.changeamount).attr("data-changeamount", rowsdata.changeamount);
- }
- $('#OrganId').combobox('setValue', rowsdata.organid==undefined?'':rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#Remark").val(rowsdata.remark);
- $("#Discount").val(rowsdata.discount==undefined?"0":rowsdata.discount);
- $("#DiscountMoney").val(rowsdata.discountmoney==undefined?"0.00":rowsdata.discountmoney);
- $("#Debt").val(Number((rowsdata.discountlastmoney==undefined?'0.00':rowsdata.discountlastmoney-rowsdata.changeamount)).toFixed(2));
- $("#AccountDay").val(rowsdata.accountday==undefined?"":rowsdata.accountday); //结算天数
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于扣预付款
- $("#AllocationProjectId").val(rowsdata.allocationprojectid);
- oldNumber = rowsdata.number; //记录编辑前的单据编号
- oldId = rowsdata.id; //记录单据Id
- var editTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- depotHeadID = rowsdata.id;
-
-
-
- //采购入库、销售出库的多账户加载
- if(rowsdata.accountidlist!=undefined && rowsdata.accountmoneylist!=undefined){
- $("#AccountId").val("many"); //下拉框选中多账户
- var accountArr = rowsdata.accountidlist.split(",");
- var accountMoneyArr = rowsdata.accountmoneylist.split(",");
- accountMoneyArr = changeListFmtPlus(accountMoneyArr) //将数组单个金额中的数值转为正数
-
- if(listSubType == "零售" || listSubType == "零售退货") {
- var manyAccountMoney = 0; //多账户合计-零售
- for (var j = 0; j < accountArr.length; j++) {
- if (accountList != null) {
- for (var i = 0; i < accountList.length; i++) {
- var account = accountList[i];
- if (accountArr[j] == account.id) {
- manyAccountMoney += accountMoneyArr[j] - 0; //多账户合计-零售
- }
- }
- }
- }
- $("#getAmount").val(manyAccountMoney); //收款金额、付款金额
- var changeAmount = $("#ChangeAmount").val()-0;
- $("#backAmount").val((manyAccountMoney-changeAmount).toFixed(2)); //找零
- }
-
- $("#AccountId").attr("data-accountArr", JSON.stringify(accountArr)).attr("data-accountMoneyArr", JSON.stringify(accountMoneyArr)); //json数据存储
- $(".many-account-ico").show(); //显示多账户的ico图标
- }
-
- //采购入库、销售出库的费用数据加载
- if(rowsdata.othermoneylist &&rowsdata.othermoneyitem){
- $("#OtherMoney").val(rowsdata.othermoney==undefined?"0":rowsdata.othermoney); //采购费用、销售费用
- var itemArr = rowsdata.othermoneylist.split(",");
- var itemMoneyArr = rowsdata.othermoneyitem.split(",");
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
-
- initTableData_material("edit",TotalPrice); //商品列表
- reject(); //撤销下、刷新商品列表
- if(pageType === "skip") {
- url = '/depotHead/addDepotHeadAndDetail'; //如果是从订单跳转过来,则此处为新增的接口
- //jshjshjsh
- $("#depotHeadFM .datagrid-body").find("[field='DepotId']").click();
- } else {
- url = '/depotHead/updateDepotHeadAndDetail?id=' + rowsdata.id; //更新接口
- }
-}
-
-//查看信息
-function showDepotHead(index){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var manyAccountMoney = 0; //多账户合计-零售
- $("#ProjectIdShow").text(rowsdata.projectName);
- $("#NumberShow").text(rowsdata.number);
- $("#OperTimeShow").text(rowsdata.opertimeStr);
- $('#OrganIdShow').text(rowsdata.organName==undefined?'':rowsdata.organName);
- $("#HandsPersonIdShow").text(rowsdata.handsPersonName);
- if(rowsdata.accountName && rowsdata.accountName!=undefined){
- $("#AccountIdShow").text(rowsdata.accountName); //结算账户
- } else {
- var accountArr = (rowsdata.accountidlist==undefined?"":rowsdata.accountidlist).split(","); //账户id列表
- var accountMoneyArr =(rowsdata.accountmoneylist==undefined?"":rowsdata.accountmoneylist).split(","); //账户金额列表
- var accountIdShow = "";
- for(var j =0;j 查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- depotHeadID = rowsdata.id;
- initTableData_material_show(TotalPrice); //商品列表-查看状态
-}
-
-//绑定操作事件
-function bindEvent(){
- showDepotHeadDetails(1,initPageSize); //初始化时自动查询
- //搜索处理
- $("#searchBtn").off("click").on("click",function(){
- showDepotHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh',
- {
- pageNumber:1,
- pageSize:initPageSize
- });
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- //$("#searchProjectId").val("");
- $("#searchState").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //检查单据编号是否存在
- function checkDepotHeadNumber() {
- var thisNumber = $.trim($("#Number").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(thisNumber.length > 0 &&( oldNumber.length ==0 || thisNumber != oldNumber))
- {
- $.ajax({
- type:"get",
- url: "/depotHead/checkIsNumberExist",
- dataType: "json",
- async : false,
- data: ({
- DepotHeadID : oldId,
- Number : thisNumber
- }),
- success: function (tipInfo)
- {
- flag = tipInfo;
- if(tipInfo)
- {
- $.messager.alert('提示','抱歉,该单据编号已经存在','warning');
- return;
- }
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','检查单据编号是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
- //保存信息
- /**
- * 2019-01-25
- * 我对这个方法的实现结果存在严重怀疑,决定重构
- * 有如下疑点:
- * 1、保存完主表,返回结果后,再发起请求去操作子表,如何保证事务的一致性(业务数据一致性)
- * 2、保存完主表后,再通过selectmax的方式去获取主表主键id完全就是看人品的不可靠的思路
- * 修改计划:
- * 2019-01-25修改零售出库相关操作
- * 修改方式,重写url,将主从表操作合并
- *
- *
- * **/
- $("#saveDepotHead").off("click").on("click",function(){
- if(!$('#depotHeadFM').form('validate')){
- return;
- }
- else {
- //如果初始编号被修改了,就要判断单据编号是否存在
- if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
- //调用查询单据编号是否重名的方法
- if(checkDepotHeadNumber()){
- return;
- }
- }
- if (editIndex != undefined) {
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- //进行明细的校验
- if(depotHeadID ==0) {
- //新增模式下
- if (!CheckData("add")) {
- return;
- }
- }
- else {
- //编辑模式下
- if (!CheckData("edit")) {
- return;
- }
- }
- var OrganId = null, ProjectId = null,AllocationProjectId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val())-0;
- var TotalPrice = $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text();
- if($('#OrganId').length){
- OrganId = $('#OrganId').combobox('getValue');
- }
- var accountMoneyList = $("#AccountId").attr("data-accountmoneyarr"); //账户金额列表-多账户
- var accountMoneyArr;
- if(accountMoneyList) {
- accountMoneyList = accountMoneyList.replace("[","").replace("]","").toString();
- var reg=new RegExp("\"","g"); //创建正则RegExp对象
- accountMoneyList = accountMoneyList.replace(reg,""); //替换所有的双引号
- accountMoneyArr = accountMoneyList.split(","); //转为数组
- }
- //零售时候,可以从会员预付款中扣款
- var thisPayType = "现付";
- var SalesmanStr = "";
- var getAccountID = $.trim($("#AccountId").val());
- if($("#AccountId").val() === "many"){ //多账户
- getAccountID = null;
- }
- var infoStr=JSON.stringify({
- Type: listType,
- SubType: listSubType,
- ProjectId: ProjectId,
- AllocationProjectId: AllocationProjectId,
- DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
- Number: $.trim($("#Number").val()),
- LinkNumber: $.trim($("#LinkNumber").val()),
- OperTime: $("#OperTime").val(),
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Salesman: SalesmanStr, //销售人员
- AccountId: getAccountID,
- ChangeAmount: ChangeAmount, //付款/收款
- TotalPrice: TotalPrice, //合计
- PayType: thisPayType, //现付/预付款
- Remark: $.trim($("#Remark").val()),
- AccountIdList: $("#AccountId").attr("data-accountarr"), //账户列表-多账户
- AccountMoneyList: accountMoneyArr ? JSON.stringify(accountMoneyArr) : "", //账户金额列表-多账户
- Discount: $.trim($("#Discount").val()),
- DiscountMoney: $.trim($("#DiscountMoney").val()),
- DiscountLastMoney: $.trim($("#DiscountLastMoney").val()),
- OtherMoney: $.trim($("#OtherMoney").val()), //采购费用、销售费用
- OtherMoneyList: $("#OtherMoney").attr("data-itemarr"), //支出项目列表-涉及费用
- OtherMoneyItem: $("#OtherMoney").attr("data-itemmoneyarr"), //支出项目金额列表-涉及费用
- AccountDay: $("#AccountDay").val() //结算天数
- });
- /**
- * 零售出库,单独操作
- * */
- if(url.indexOf("/depotHead/addDepotHeadAndDetail")>=0){
- addDepotHeadAndDetail(url,infoStr);
- return;
- }else if(url.indexOf("/depotHead/updateDepotHeadAndDetail")>=0){
- updateDepotHeadAndDetail(url,infoStr,preTotalPrice);
- return;
- }
- }
- });
-
- //打印单据
- $("#printDepotHeadShow").off("click").on("click",function(){
- var tableString = $("#depotHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event){
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="State"||obj.id=="Number"))
- {
- $("#saveDepotHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber"||obj.id=="searchMaterial"))
- {
- $("#searchBtn").click();
- }
- });
-
- //优惠率输入框事件
- $("#Discount").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountNum = $(this).val();
- var discountMoney = (discountNum/100*totalPrice).toFixed(2);
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#DiscountMoney").val(discountMoney); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //优惠金额输入框事件
- $("#DiscountMoney").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountMoney = $(this).val();
- var discount = (discountMoney/totalPrice).toFixed(2)*100;
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#Discount").val(discount); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //付款、收款输入框事件
- $("#ChangeAmount").off("keyup").on("keyup",function(){
- var discountLastMoney = $("#DiscountLastMoney").val();
- var changeAmount = $(this).val();
- var debtMoney = (discountLastMoney - changeAmount).toFixed(2);
- $("#Debt").val(debtMoney); //本次欠款
- });
-
- //多账户结算窗口弹出事件
- function depotHeadAccountDlgFun(){
- $('#depotHeadAccountDlg').dialog('open').dialog('setTitle','
多账户结算');
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").remove(); //先移除输入栏目
- $("#accountMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#depotHeadAccountDlg .tabs-tmp .account-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#depotHeadAccountDlg .tabs-tmp tbody").html();
- var accountDlgHead = $("#depotHeadAccountDlg .account-head-tmp");
- accountDlgHead.after(contentTmp);
- }
-
- //获取账户信息
- function accountDlgFun() {
- var options = "";
- if(accountList !=null){
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- }
- $(".account-id-dlg").empty().append("").append(options);
- }
- }
- accountDlgFun(); //获取账户信息
- $("#depotHeadAccountDlg .tabs-tmp").hide(); //隐藏模板
-
- //账户金额输入框事件-多账户
- $("#depotHeadAccountDlg .account-dlg .account-money-dlg").off("keyup").on("keyup",function(){
- var totalAccoutNum = 0;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var eachAccountMoney = $(this).find(".account-money-dlg").val()-0;
- totalAccoutNum += eachAccountMoney;
- });
- $("#accountMoneyTotalDlg").text(totalAccoutNum);
- });
-
- //结算多账户列表的切换事件
- $("#depotHeadAccountDlg .account-dlg .account-id-dlg").off("change").on("change",function(){
- var selectAccount = $(this).children('option:selected').text();
- if(selectAccount === ""){
- var thisMoneyDom = $(this).closest(".account-content-tmp").find(".account-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text() - 0;
- $("#accountMoneyTotalDlg").text(accountMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //账户为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveDepotHeadAccountDlg").off("click").on("click", function(){
- //完成多账户的json数据存储
- var accountArr = []; //账户id数组
- var accountMoneyArr = []; //账户金额数组
- var errorIndex = -1;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var thisAccId = $(this).find(".account-id-dlg").val();
- var thisAccMoney = $(this).find(".account-money-dlg").val();
- if(!thisAccId && thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && !thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && thisAccMoney) {
- accountArr.push(thisAccId);
- accountMoneyArr.push(thisAccMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var discountLastMoneyNum =$("#DiscountLastMoney").val()-0; //优惠后金额
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text()-0; //本次付款或者收款
- if(accountMoneyTotal===0){
- $.messager.alert('错误提示',"请填写金额后保存",'warning');
- return;
- }
- if(accountArr.length && accountMoneyArr.length) {
- $("#AccountId").attr("data-accountArr",JSON.stringify(accountArr)).attr("data-accountMoneyArr",JSON.stringify(accountMoneyArr)); //json数据存储
- }
- $("#ChangeAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
- $("#Debt").val((discountLastMoneyNum-accountMoneyTotal).toFixed(2)); //本次欠款
- $("#depotHeadAccountDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#AccountId").attr("data-accountArr")){
- $("#depotHeadAccountDlg").dialog('close');
- }
- else {
- $("#depotHeadAccountDlg").dialog('close');
- $("#AccountId").val("").removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- }
- //多账户-取消按钮
- $("#cancelDepotHeadAccountDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //多账户-右上角的关闭按钮
- $("#depotHeadAccountDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
- }
- //点击多账户,弹出输入框
- $("#AccountId").off("change").on("change",function(){
- var selectText = $(this).children('option:selected').text();
- if(selectText === "多账户"){
- $("#ChangeAmount").prop("readonly","readonly");
- depotHeadAccountDlgFun();
- $(".many-account-ico").show(); //显示多账户小图标
- }
- else{
- $(this).removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- });
-
- //结算账户-多账户小图标-点击事件
- $(".many-account-ico").off("click").on("click",function(){
- depotHeadAccountDlgFun();
- //给弹窗赋值-多账户数据
- var accountArr = $("#AccountId").attr("data-accountArr");
- accountArr = JSON.parse(accountArr);
- var accountMoneyArr = $("#AccountId").attr("data-accountMoneyArr");
- accountMoneyArr = JSON.parse(accountMoneyArr);
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".account-id-dlg").val(accountArr[index]);
- $(this).find(".account-money-dlg").val(accountMoneyArr[index]);
- });
- $("#accountMoneyTotalDlg").text($("#ChangeAmount").val());
- });
-
- //点击采购费用、销售费用的事件
- $(".other-money-ico").off("click").on("click",function(){
- $('#otherMoneyDlg').dialog('open').dialog('setTitle','
'+ listSubType +'费用');
- $("#otherMoneyDlg .money-dlg .money-content-tmp").remove(); //先移除输入栏目
- $("#otherMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#otherMoneyDlg .tabs-tmp .money-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#otherMoneyDlg .tabs-tmp tbody").html();
- var moneyDlgHead = $("#otherMoneyDlg .money-head-tmp");
- moneyDlgHead.after(contentTmp);
- }
-
- //获取支出项目信息
- function moneyDlgFun() {
- var options = "";
- if(outItemList !=null){
- for(var i = 0 ;i < outItemList.length;i++) {
- var money = outItemList[i];
- options += '';
- }
- $(".money-id-dlg").empty().append("").append(options);
- }
- }
- moneyDlgFun(); //获取支出项目信息
- $("#otherMoneyDlg .tabs-tmp").hide(); //隐藏模板
-
- //支出项目的金额输入框事件
- $("#otherMoneyDlg .money-dlg .other-money-dlg").off("keyup").on("keyup",function(){
- var totalMoneyNum = 0;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var eachOtherMoney = $(this).find(".other-money-dlg").val()-0;
- totalMoneyNum += eachOtherMoney;
- });
- $("#otherMoneyTotalDlg").text(totalMoneyNum);
- });
-
- //支出项目列表的切换事件
- $("#otherMoneyDlg .money-dlg .money-id-dlg").off("change").on("change",function(){
- var selectItem = $(this).children('option:selected').text();
- if(selectItem === ""){
- var thisMoneyDom = $(this).closest(".money-content-tmp").find(".other-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text() - 0;
- $("#otherMoneyTotalDlg").text(otherMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //支出项目为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveOtherMoneyDlg").off("click").on("click", function(){
- //完成支出项目的json数据存储
- var itemArr = []; //支出项目id数组
- var itemMoneyArr = []; //支出项目金额数组
- var errorIndex = -1;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var thisId = $(this).find(".money-id-dlg").val();
- var thisMoney = $(this).find(".other-money-dlg").val();
- if(!thisId && thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && !thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && thisMoney) {
- itemArr.push(thisId);
- itemMoneyArr.push(thisMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text()-0; //合计金额
- if(otherMoneyTotal === 0){ //0的时候清空缓存数据
- $("#OtherMoney").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr");
- }
- if(itemArr.length && itemMoneyArr.length) {
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
- $("#OtherMoney").val(otherMoneyTotal); //给采购费用、销售费用赋值
- $("#otherMoneyDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#OtherMoney").attr("data-itemArr")){
- $("#otherMoneyDlg").dialog('close');
- }
- else {
- $("#otherMoneyDlg").dialog('close');
- $("#OtherMoney").val("").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr"); //将下拉置空并把缓存参数清空
- }
- }
- //费用-取消按钮
- $("#cancelOtherMoneyDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //费用-右上角的关闭按钮
- $("#otherMoneyDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
-
- //给弹窗赋值-采购费用、销售费用数据
- var itemArr = $("#OtherMoney").attr("data-itemArr");
- itemArr = JSON.parse(itemArr);
- var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr");
- itemMoneyArr = JSON.parse(itemMoneyArr);
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".money-id-dlg").val(itemArr[index]);
- if(itemMoneyArr[index]!="undefined"){
- $(this).find(".other-money-dlg").val(itemMoneyArr[index]);
- }
- });
- $("#otherMoneyTotalDlg").text($("#OtherMoney").val());
- });
-}
-
-function showDepotHeadDetails(pageNo,pageSize){
- var materialParam = $.trim($("#searchMaterial").val());
- var beginTime = $.trim($("#searchBeginTime").val());
- var endTime = $.trim($("#searchEndTime").val());
- if(beginTime) {
- beginTime = beginTime + ' 00:00:00';
- }
- if(endTime) {
- endTime = endTime + ' 23:59:59';
- }
- $.ajax({
- type: "get",
- url: "/depotHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- subType: listSubType,
- state: $.trim($("#searchState").val()),
- number: $.trim($("#searchNumber").val()),
- beginTime: beginTime,
- endTime: endTime,
- materialParam: materialParam,
- depotIds: depotString
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- return;
- }
- });
-}
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#depotHeadFM .datagrid-body");
- var footer =$("#depotHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
- //点击商品下拉框,自动加载数量、单价、金额
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //点击库存文本框,字段计算库存
- body.find("[field='Stock']").find(input).off("click").on("click",function(){
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- var monthTime = getNowFormatMonth();
- if(depotId && mId){
- var ratio = body.find("[field='Unit']").find(input).attr("data-ratio");
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //在新增的时候,这个ratio有值;在编辑的时候,这个ratio为undefined
- var type = "click"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratio, type);
- }
- else{
- body.find("[field='Stock']").find(input).val(0).attr("data-stock",0); //加载库存数据
- }
- });
- //修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计
- body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber =$(this).val()-0; //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
-
- });
- //修改单价,自动计算金额和合计
- body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice =$(this).val()-0; //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击单价,自动提示参考价格列表
- body.find("[field='UnitPrice']").find(input).off("click").on("click",function(){
- var self = this;
- var mValue = body.find("[field='MaterialId'] .combo-value").attr("value"); //获取选中的商品id
- if(!mValue) {
- return;
- }
- else {
- return;
- }
- });
- //修改含税单价,自动计算单价、金额、税额、价税合计和合计
- body.find("[field='TaxUnitPrice']").find(input).off("keyup").on("keyup",function(){
- var TaxUnitPrice =$(this).val()-0; //含税单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var UnitPrice = TaxUnitPrice/(1+taxRate/100); //计算单价
- body.find("[field='UnitPrice']").find(input).val((UnitPrice).toFixed(2)); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改金额,自动计算单价、税额、价税合计和合计
- body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var AllPrice =$(this).val()-0; //金额
- var UnitPrice = (AllPrice/OperNumber).toFixed(2);
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税率,自动计算含税单价、税额、价税合计和合计
- body.find("[field='TaxRate']").find(input).off("keyup").on("keyup",function(){
- var taxRate =$(this).val()-0; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税额,自动计算税率、含税单价、价税合计和合计
- body.find("[field='TaxMoney']").find(input).off("keyup").on("keyup",function(){
- var taxMoney =$(this).val()-0; //税额
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = taxMoney/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改价税合计,自动计算税率、含税单价、税额和合计
- body.find("[field='TaxLastMoney']").find(input).off("keyup").on("keyup",function(){
- var taxLastMoney =$(this).val()-0; //价税合计
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = (taxLastMoney-AllPrice)/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
-
- //加载税率
- if(thisTaxRate) {
- body.find("[field='TaxRate']").find(input).val(thisTaxRate);
- }
- else {
- body.find("[field='TaxRate']").find(input).val(0); //默认为0
- }
-
- //在商品类型加载 组装件、普通子件
- var mType = body.find("[field='MType']");
- var rowListLength = mType.find(input).closest(".datagrid-row").attr("datagrid-row-index");
- var mTypeValue = "组合件";
- if(rowListLength > 0){
- mTypeValue = "普通子件";
- }
- mType.find(input).val(mTypeValue).prop("readonly","readonly");
- },500);
-}
-
-//结束编辑
-function endEditing() {
- if (editIndex == undefined) { return true }
- if ($('#materialData').datagrid('validateRow', editIndex)) {
- //仓库信息
- var edDepot = $('#materialData').datagrid('getEditor', {index:editIndex,field:'DepotId'});
- var DepotName = $(edDepot.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName;
- //商品信息
- var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'});
- var MaterialName = $(edMaterial.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName;
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#materialData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append(){
- if (endEditing()) {
- $('#materialData').datagrid('appendRow', {DepotId:defDepotId});
- editIndex = $('#materialData').datagrid('getRows').length - 1;
- $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function batchDel(){
- /**
- * 重写一下删除的逻辑
- * 获取所有选中行,直接从列表中移除
- * 点击保存时,将需要后台删除的数据提交到服务器
- * **/
- /**
- * create by: qiankunpingtai
- * create time: 2019/3/20 16:26
- * description:
- * 这个地方比较坑的,花了一个多小时才搞明白为什么
- * 1、删除之前必须先调用endEditing结束编辑
- * 2、如果只是调用endEditing结束编辑那么正在编辑行的被选中状态会被去掉
- * 所以要在调用endEditing先获取选中的行
- */
- //如果编辑的行一开始是选中状态,结束编辑后仍然是选中状态
- var row = $('#materialData').datagrid('getChecked');
- if (endEditing()) {
- if (row.length == 0) {
- $.messager.alert('删除提示', '没有记录被选中!', 'info');
- return;
- }
- if (row.length > 0) {
- $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条单据信息吗?', function (r) {
- if (r) {
- for (var i = 0; i < row.length; i++) {
- $('#materialData').datagrid('deleteRow', $('#materialData').datagrid("getRowIndex", row[i]));
- }
- }
- });
- }
- }
-}
-function removeit(){
- if (editIndex == undefined) { return }
- $('#materialData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#materialData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData(type) {
- var change = $('#materialData').datagrid('getChanges').length;
- if(type =="add" && !change) {
- $.messager.alert('提示','请输入明细信息!','warning');
- return false;
- }
- var row = $('#materialData').datagrid('getRows');
- if(!row.length){
- $.messager.alert('提示',"请输入明细信息!",'info');
- return false;
- }
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if (row[i].DepotId == "" || row[i].MaterialId == "" || row[i].OperNumber == "" || row[i].UnitPrice === "" || row[i].AllPrice === "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-
-/**
- * 新增单据主表及单据子表
- * */
-function addDepotHeadAndDetail(url,infoStr){
- var inserted = null;
- if(pageType === "skip") {
- inserted = $("#materialData").datagrid('getChanges', "updated");
- } else {
- inserted = $("#materialData").datagrid('getChanges', "inserted");
- }
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated)
- }),
- success: function (tipInfo){
-
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
-
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
-
-
- });
-}
-/**
- * 修改单据主表及单据子表
- * */
-function updateDepotHeadAndDetail(url,infoStr,preTotalPrice){
- var inserted = $("#materialData").datagrid('getChanges', "inserted");
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- id:url.substring(url.lastIndexOf("?id=")+4,url.length),
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- preTotalPrice:preTotalPrice
- }),
- success: function (tipInfo){
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
- if (endEditing()) {
- $('#materialData').datagrid('acceptChanges');
- }
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-
-
-
diff --git a/erp_web/js/pages/materials/other_in_list.js b/erp_web/js/pages/materials/other_in_list.js
deleted file mode 100644
index f8987f99..00000000
--- a/erp_web/js/pages/materials/other_in_list.js
+++ /dev/null
@@ -1,2417 +0,0 @@
-//初始化界面
-var defDepotId = null;
-var kid = sessionStorage.getItem("userId");
-var pageType = getUrlParam('t'); //获取页面类型传值
-var depotList = null;
-var depotID = null;
-var supplierList = null;
-var supplierID = null;
-var personList = null;
-var personID = null;
-var ProjectSearch=null;
-var userBusinessList=null;
-var userdepot=null;
-var url;
-var depotHeadID = 0;
-var preTotalPrice = 0; //前一次加载的金额
-var orgDepotHead = "";
-var editIndex = undefined;
-/**默认编号有意义吗,不如空着吧*/
-var orgDefaultId=''; //单位默认编号
-var orgDefaultList; //存储查询出来的会员列表
-var accountList; //账户列表
-var outItemList; //支出项目列表
-var thisTaxRate = 0; //当前税率,选择供应商或者客户的时候设置
-var oldNumber = ""; //编辑前的单据编号
-var oldId = 0; //编辑前的单据Id
-var otherColumns = true; //明细中的‘别名’列是否显示
-var btnEnableList = getBtnStr(); //获取按钮的权限
-var mPropertyList = ""; //商品属性列表
-var defaultAccountId = 0; //默认账户id
-//改变宽度和高度
-$("#searchPanel").panel({width:webW-2});
-$("#tablePanel").panel({width:webW-2});
-var listTitle = "其它入库列表"; //单据标题
-var depotString = "|"; //店铺id列表
-var listType = "入库";//入库 出库
-var listSubType = "其它"; //采购 销售等
-var payTypeTitle = "隐藏"; //付款 收款
-var organUrl = "/supplier/findBySelect_sup"; //组织数据接口地址
-var amountNum ="QTRK";//单据编号开头字符
-$(function(){
- //初始化系统基础信息
- initSystemData_UB();
- initSelectInfo_UB();
- initSystemData_depot();
- initSelectInfo_depot();
- initSystemData_person();
- initSelectInfo_person();
- initSystemData_account();
- initSelectInfo_account();
- initSupplier(); //供应商
- initSalesman(); //销售人员
- initOutItemList(); //初始化支出项目
- initMProperty(); //初始化商品属性
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
-});
-
-//初始化系统基础信息
-function initSystemData_UB(){
- $.ajax({
- type:"get",
- url: "/userBusiness/getBasicData",
- data: ({
- KeyId:kid,
- Type:"UserDepot"
- }),
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if (res && res.code === 200) {
- userBusinessList = res.data.userBusinessList;
- }
- else {
- userBusinessList = null;
- }
- }
- });
-
-}
-//初始化页面选项卡
-function initSelectInfo_UB(){
-
- if(userBusinessList !=null)
- {
- if(userBusinessList.length>0)
- {
- //用户对应的仓库列表 [1][2][3]...
- userdepot =userBusinessList[0].value;
- }
- }
-}
-
-
-//初始化系统基础信息
-function initSystemData_depot(){
- $.ajax({
- type:"get",
- url: "/depot/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200){
- depotList = res.data;
- } else {
- $.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error');
- return;
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_depot(){
- var options = "";
-
- if(depotList !=null)
- {
- options = "";
- for(var i = 0 ;i < depotList.length;i++)
- {
- var depot = depotList[i];
-
- if(userdepot!=null)
- {
- if(userdepot.indexOf("["+depot.id+"]")!=-1)
- {
- if(depot.isDefault){
- defDepotId = depot.id;
- }
- options += '';
- depotString = depotString + depot.id + ",";
- }
- }
- if(depot.type === 1){
- depotString = depotString + depot.id + ",";
- }
- }
- depotString = depotString.substring(1, depotString.length-1);
- $("#ProjectId").empty().append(options);
- $("#AllocationProjectId").empty().append(options);
- $("#searchProjectId").empty().append('').append(options);
- }
-}
-
-//初始化供应商、客户、散户信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onLoadSuccess: function(res) {
- var data = $(this).combobox('getData');
- for(var i = 0; i<= data.length; i++){
- if(data && data[i] && data[i].supplier === "非会员"){
- orgDefaultId = data[i].id;
- }
- }
- },
- onSelect: function(rec){
- $.ajax({
- type:"get",
- url: "/supplier/findById",
- data: {
- supplierId: rec.id
- },
- dataType: "json",
- success: function (res){
- if(res && res.code === 200) {
- if(res.data && res.data[0]){
- thisTaxRate = res.data[0].taxRate; //设置当前的税率
- }
- }
- },
- error:function(){
-
- }
- });
- }
- });
-}
-
-//初始化销售人员
-function initSalesman(){
- $('#Salesman').combobox({
- url: "/person/getPersonByNumType?type=1",
- valueField:'id',
- textField:'name',
- multiple: true
- });
-}
-
-//初始化收入项目列表
-function initOutItemList(){
- $.ajax({
- type:"get",
- url: "/inOutItem/findBySelect?type=out",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res){
- if(res){
- outItemList = res;
- }
- },
- error:function(){
-
- }
- });
-}
-
-//初始化商品属性
-function initMProperty(){
- $.ajax({
- type: "get",
- url: "/materialProperty/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- name: ""
- }),
- currentPage: 1,
- pageSize: 100
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- var thisRows = res.data.page.rows;
- for (var i = 0; i < thisRows.length; i++) {
- if (thisRows[i].enabled) {
- mPropertyList += thisRows[i].nativename + ",";
- }
- }
- if (mPropertyList) {
- mPropertyList = mPropertyList.substring(0, mPropertyList.length - 1);
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化系统基础信息
-function initSystemData_person(){
- $.ajax({
- type:"get",
- url: "/person/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- personList = res.data.personList;
- }
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_person(){
- var options1 = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="仓管员")
- {
- options1 += '';
- }
- }
- $("#HandsPersonId").empty().append(options1);
- }
-}
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null){
- options = "";
- options += "";
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- if(account.isdefault) {
- defaultAccountId = account.id; //给账户赋值默认id
- }
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#depotHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- if(pageType === "skip") {
- var oldRowInfo = sessionStorage.getItem("rowInfo");
- editDepotHead(oldRowInfo); //自动弹出编辑框,带缓存数据
- }
- var hideType = undefined;
- var isHiddenStatus = true;
- if(payTypeTitle === "隐藏"){
- hideType = true; //隐藏当前列
- }
- var tableToolBar = [
- {
- id:'addDepotHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addDepotHead();
- }
- },
- {
- id:'deleteDepotHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteDepotHead();
- }
- }
- ];
- //如果允许的按钮列表中存在就显示,3-代表审核|反审核的权限
- if(btnEnableList && btnEnableList.indexOf(3)>-1){
- isHiddenStatus = false; //显示
- tableToolBar.push({
- id:'okDepotHead',
- text:'审核',
- iconCls:'icon-ok',
- handler:function() {
- setStatusFun();
- }
- },
- {
- id:'undoDepotHead',
- text:'反审核',
- iconCls:'icon-undo',
- handler:function() {
- setUnStatusFun();
- }
- });
- }
- else {
- isHiddenStatus = true; //隐藏
- }
- var isShowLastMoneyColumn = true; //是否显示优惠后金额和价税合计,true为隐藏,false为显示
- var isShowOrganNameColumn = false; //是否显示供应商、客户等信息,true为隐藏,false为显示
- var organNameTitle = "供应商名称"; //组织名称标题
- var opWidth = 90; //操作宽度
- var isShowSkip = false; //是否显示跳转按钮
- var opTitle = ""; //跳转按钮的标题
- $('#tableData').datagrid({
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: true,
- //交替出现背景
- striped : true,
- pageSize: 10,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:opWidth,
- formatter:function(value, rec,index) {
- var str = '';
- var orgId = rec.organid? rec.organid:0;
- str += '
';
- str += '
';
- str += '
';
- if(isShowSkip) {
- str += '
';
- }
- return str;
- }
- },
- { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
- { title: '单据编号',field: 'number',width:135, formatter:function (value,rec) {
- if(rec.linknumber) {
- return value + "[转]";
- } else {
- return value;
- }
- }
- },
- { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
- if(value) {
- return value.replace(",",",");
- }
- }
- },
- { title: '单据日期',field: 'opertimeStr',width:130},
- { title: '操作员',field: 'operpersonname',width:60},
- { title: '金额合计',field: 'totalprice',width:60},
- { title: '含税合计',field: 'totaltaxlastmoney',hidden:isShowLastMoneyColumn,width:60,formatter:function(value,rec){
- return (rec.discountmoney + rec.discountlastmoney).toFixed(2);
- }
- },
- { title: '优惠后金额',field: 'discountlastmoney',hidden:isShowLastMoneyColumn,width:80},
- { title: payTypeTitle,field: 'changeamount',width:50,hidden:hideType},
- { title: '状态',field: 'status',hidden:isHiddenStatus, width:70,align:"center",formatter:function(value){
- if(value === "0") {
- return "未审核";
- } else if(value === "1") {
- return "已审核";
- } else if(value === "2") {
- }
- }
- }
- ]],
- toolbar:tableToolBar,
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//查找库存的方法
-function findStockNumById(depotId, mId, monthTime, body, input, ratio, type){
- var thisRatio = 1; //比例
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (rec) {
- if(rec && rec.code === 200 && rec.data && rec.data[0]) {
- var loadRatio = 1; //在单位输入框上面加载比例字段
- if(rec.data[0].unit) { //如果存在计量单位信息
- loadRatio = 1;
- }
- else{
- var unitName = rec.data[0].unitName;
- if(unitName) {
- thisRatio = unitName.substring(unitName.indexOf(":")+1).replace(")","");
- unitName = unitName.substring(0, unitName.indexOf("("));
- }
-
- }
- //查询库存
- $.ajax({
- type: "get",
- url: '/depotItem/findStockNumById',
- data:{
- projectId: depotId,
- materialId: mId
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if (res.data && res.data.page && res.data.page[0]) {
- var thisStock = res.data.page[0].thisSum;
- if (type == "select") { //选择下拉框的时候
- if (ratio != undefined && ratio != 1) {
- loadRatio = ratio;
- }
- }
- else if (type == "click") { //点击库存的时候
- if (ratio != undefined) {
- loadRatio = ratio;
- }
- }
- thisStock = (thisStock / loadRatio).toFixed(2);
- body.find("[field='Stock']").find(input).val(thisStock).attr("data-stock", res.data.page[0].thisSum); //加载库存数据
- }
- else {
- body.find("[field='Stock']").find(input).val(0).attr("data-stock", 0); //加载库存数据
- }
- body.find("[field='Stock']").find(input).prop("readonly", "readonly"); //设置库存数据为只读
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
- }
- },
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- }
- });
-}
-//优惠率、合计的统计方法
-function statisticsFun(body,UnitPrice,OperNumber,footer,taxRate){
- var TotalPrice = 0;
- var taxLastMoneyTotal = 0;
- //金额的合计
- body.find("[field='AllPrice']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + UnitPrice*OperNumber;
- footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); //金额的合计
- //价税合计的总计
- body.find("[field='TaxLastMoney']").each(function(){
- if($(this).find("div").text()!==""){
- taxLastMoneyTotal = taxLastMoneyTotal + (parseFloat($(this).find("div").text().toString())-0);
- }
- });
- taxLastMoneyTotal = taxLastMoneyTotal + (UnitPrice*OperNumber*(1+taxRate/100));
- footer.find("[field='TaxLastMoney']").find("div").text((taxLastMoneyTotal).toFixed(2)); //价税合计的页脚总计
- var discount = $("#Discount").val(); //优惠率
- var discountMoney = (taxLastMoneyTotal*discount/100).toFixed(2);
- $("#DiscountMoney").val(discountMoney);//优惠金额
- var discountLastMoney = (taxLastMoneyTotal*(1-discount/100)).toFixed(2)
- $("#DiscountLastMoney").val(discountLastMoney);//优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
-
-}
-//初始化表格数据-商品列表-编辑状态
-function initTableData_material(type,TotalPrice){
- var body,footer,input; //定义表格和文本框
- var ratio = 1; //比例-品名专用
- var ratioDepot = 1; //比例-仓库用
- var monthTime = getNowFormatMonth();
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var depotHeadName = ""; //仓库名称
- var depotUrl = ""; //仓库接口地址
- var depotTextField = ""; //仓库下拉名称
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var anotherDepotUrl = ""; //对方仓库接口地址
- var anotherDepotTextField = "";
- depotHeadName = "仓库名称";
- depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- depotTextField = "depotName";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialData').datagrid({
- height:245,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: '商品类型',field: 'MType',editor:'validatebox',hidden:isShowMaterialTypeColumn,width:80},
- { title: depotHeadName, field: 'DepotId', editor: 'validatebox', width: 90,
- formatter: function (value, row, index) {
- return row.DepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: depotTextField,
- method: 'get',
- url: depotUrl,
- onSelect:function(rec){
- var depotId = rec.id;
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- if(mId){
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratioDepot, type);
- }
- }
- }
- }
- },
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialId',width:230,
- formatter:function(value,row,index){
- return row.MaterialName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'MaterialName',
- method:'get',
- url: "/material/findBySelect",
- panelWidth: 300, //下拉框的宽度
- //全面模糊匹配,过滤字段
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onBeforeLoad: function(param){
- param.mpList = mPropertyList; //商品属性
- },
- onSelect:function(rec){
- if(rec) {
- var mId = rec.Id;
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (res) {
- if(res && res.code === 200 && res.data && res.data[0]) {
- var retailPrice = res.data[0].retailprice-0; //零售价格
- var presetPriceOne = res.data[0].presetpriceone-0; //预计采购价
- var presetPriceTwo = res.data[0].presetpricetwo-0; //批发价
- var firstInUnit = res.data[0].firstinunit; //首选入库单位
- var firstOutUnit = res.data[0].firstoutunit; //首选出库单位
- var basicPresetPriceOne = ""; //多单位-入库-基础价格
- var basicPresetPriceTwo = ""; //多单位-出库-基础价格
- var retailPriceOne = ""; //多单位-入库-零售价格
- var otherPresetPriceOne = ""; //多单位-入库-其他价格
- var otherPresetPriceTwo = ""; //多单位-出库-其他价格
- var retailPriceTwo = ""; //多单位-出库-零售价格
- var basicUnit = ""; //基础单位
- var otherUnit = ""; //其他单位
- if(!res.data[0].unit){
- var ps = res.data[0].pricestrategy;
- var psObj = JSON.parse(ps);
- basicPresetPriceOne = psObj[0].basic.PresetPriceOne-0;
- basicPresetPriceTwo = psObj[0].basic.PresetPriceTwo-0;
- retailPriceOne = psObj[0].basic.RetailPrice-0;
- otherPresetPriceOne = psObj[1].other.PresetPriceOne-0;
- otherPresetPriceTwo = psObj[1].other.PresetPriceTwo-0;
- retailPriceTwo = psObj[1].other.RetailPrice-0;
- basicUnit = psObj[0].basic.Unit;
- otherUnit = psObj[1].other.Unit;
- }
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- if(res.data[0].unit){ //如果存在计量单位信息
- ratio = 1; //重置比例为1
- body.find("[field='Unit']").find(input).val(res.data[0].unit); //设置-计量单位信息
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- body.find("[field='Unit']").find(input).off("click"); //移除点击事件
- body.find("[field='Unit']").find(input).attr("data-ratio",ratio); //修改比例缓存信息
- }
- else {
- var unitName = res.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- var loadRatio = 1; //在单位输入框上面加载比例字段
- body.find("[field='Unit']").find(input).val(unitSetInput).attr("data-ratio", loadRatio); //设置-首选单位
-
- body.find("[field='Unit']").find(input).off("click").on("click",function(){
- if(basicUnit && otherUnit) {
- var self = this;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- " + basicUnit + "
";
- temp +="- " + otherUnit + "
";
- temp +="
";
- temp +="
";
- if($('.unit-list').length){
- $('.unit-list').remove(); //如果存在计量单位列表先移除
- }
- else {
- $(self).after(temp); //加载列表信息
- }
- //计量单位列表的单击事件
- $('.unit-list ul li').off("click").on("click",function(){
- var unit = $(this).text();
- var thisRatio = $(this).attr("data-ratio"); //获取比例
- $(self).val(unit).attr("data-ratio", thisRatio);
- $(self).keyup(); //模拟键盘操作
- $('.unit-list').remove(); //移除计量单位列表
- var stock = body.find("[field='Stock']").find(input).attr("data-stock"); //从缓存中取值
- var type = $(this).attr("data-type");
- var UnitPrice = 0;
- if(type === "basic"){
- UnitPrice = basicPresetPriceOne;
- body.find("[field='Stock']").find(input).val(stock); //修改库存
- }
- else if(type === "other"){
- UnitPrice = otherPresetPriceOne;
- body.find("[field='Stock']").find(input).val((stock/ratio).toFixed(2)); //修改库存
- }
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //获取数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击空白处移除计量单位列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.unit-list').remove(); //移除计量单位列表
- });
- }
- });
- }
- var detailPrice = 0; //明细列表-单价
- if(res.data[0].unit) { //如果存在计量单位信息
- detailPrice = presetPriceOne;
- }
- else {
- if (firstInUnit == basicUnit) {
- detailPrice = basicPresetPriceOne;
- }
- else if (firstInUnit == otherUnit) {
- detailPrice = otherPresetPriceOne;
- }
- }
- body.find("[field='OperNumber']").find(input).val(1); //数量初始化为1
- //单价和总价赋值
- if(!detailPrice) {
- detailPrice = 0;
- }
- body.find("[field='UnitPrice']").find(input).val(detailPrice);
- body.find("[field='AllPrice']").find(input).val(detailPrice);
- var taxRate = body.find("[field='TaxRate']").find(input).val()-0; //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((detailPrice*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,detailPrice,1,footer,taxRate);
-
- //查询库存信息
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- if(depotId) {
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, loadRatio, type);
- }
- }
- },
- error: function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- }
- });
- }
- }
- }
- }
- },
- { title: '库存',field: 'Stock',editor:'validatebox',width:70},
- { title: anotherDepotHeadName, field: 'AnotherDepotId',editor:'validatebox',hidden:isShowAnotherDepot,width:90,
- formatter: function (value, row, index) {
- return row.AnotherDepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: anotherDepotTextField,
- method: 'get',
- url: anotherDepotUrl
- }
- }
- },
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率(%)',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batchDel(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = 0;
- var TaxLastMoney = 0;
- var DiscountMoney = $("#DiscountMoney").val()-0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoney").val()-0; //优惠后金额
- if(type === "edit") {
- AllPrice = TotalPrice;
- TaxLastMoney = DiscountMoney + DiscountLastMoney;
- }
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": TaxLastMoney
- });
- data.footer = array;
- $("#materialData").datagrid('loadData',data);
- //如果是订单跳转到采购或销售
- if(pageType === "skip") {
- var skipList = $("#depotHeadFM .datagrid-body tr");
- //逐条自动点击每行数据
- skipList.each(function (i) {
- setTimeout(function () {
- skipList.eq(i).find("[field='Stock']").click();
- },(i+1)*1000);
- });
- }
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//初始化表格数据-商品列表-查看状态
-function initTableData_material_show(TotalPrice){
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var depotHeadName = ""; //仓库的列的标题
- depotHeadName = "仓库名称";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialDataShow').datagrid({
- height:245,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- onClickRow: onClickRow,
- columns:[[
- { title: '商品类型',field: 'MType',width:80, hidden:isShowMaterialTypeColumn},
- { title: depotHeadName,field: 'DepotName',editor:'validatebox',width:90},
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialName',width:230},
- { title: anotherDepotHeadName,field: 'AnotherDepotName',hidden:isShowAnotherDepot,width:90},
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validattebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = TotalPrice;
- var DiscountMoney = $("#DiscountMoneyShow").text() - 0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoneyShow").text() - 0; //优惠后金额
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": DiscountMoney + DiscountLastMoney
- });
- data.footer = array;
- $("#materialDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showDepotHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除单据信息
-function deleteDepotHead(depotHeadID, thisOrganId, totalPrice, status){
- if(status == "1" || status == "2") {
- $.messager.alert('删除提示','已审核和已转的单据不能删除!','warning');
- return;
- }
- $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
- if (r) {
- $.ajax({
- type:"post",
- // url: "/depotHead/" + depotHeadID + "/delete",
- url: "/depotHead/deleteDepotHeadAndDetail",
- dataType: "json",
- data:{
- id: depotHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
- return;
- }
- });
-
- }
- });
-}
-
-//订单转采购或销售
-function skipDepotHead(index, status){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- if(status == "0" || status == "2") {
- $.messager.alert('提示','未审核和已转的单据禁止操作!','warning');
- } else {
- sessionStorage.setItem("rowInfo", JSON.stringify(rowsdata)); //将单据信息存入缓存中
- }
-}
-
-//批量删除单据信息
-function batDeleteDepotHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条单据信息吗?',function(r)
- {
- if (r) {
- var ids = "";
- for (var i = 0; i < row.length; i++) {
- if (i == row.length - 1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- if (ids) {
- //批量删除
- $.ajax({
- type: "post",
- // url: "/depotHead/batchDelete",
- url: "/depotHead/batchDeleteDepotHeadAndDetail",
- dataType: "json",
- async: false,
- data: ({
- ids: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除单据信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('删除提示','没有能删除的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量审核
-function setStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('审核确认','确定要审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: "1",
- depotHeadIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('审核提示', '审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('审核提示','审核信息异常,请稍后再试!','error');
- return;
- }
- });
- } else {
- $.messager.alert('审核提示','没有能审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量反审核
-function setUnStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('反审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('反审核确认','确定要反审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type: "post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async: false,
- data: ({
- status: "0",
- depotHeadIDs: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('反审核提示', '反审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('反审核提示', '反审核信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('反审核提示','没有能反审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//生成单据编号
-function buildNumber() {
- $.ajax({
- type: "get",
- url: "/depotHead/buildNumber",
- success:function(res){
- if(res && res.code === 200){
- var obj = res.data;
- var defaultNumber = obj.DefaultNumber;
- var newNumber = amountNum + defaultNumber;
- $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
- }
- },
- error:function(){
- $.messager.alert('提示','生成单据编号失败!','error');
- }
- });
-}
-
-//新增信息
-function addDepotHead(){
- $('#depotHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- buildNumber(); //生成单据编号
- //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为0
- $("#Discount").val(0);
- $("#DiscountMoney").val(0);
- $("#DiscountLastMoney").val(0);
- $("#ChangeAmount").val(0);
- $("#Debt").val(0);
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- var addTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgDepotHead = "";
- depotHeadID = 0;
- initTableData_material("add"); //商品列表
- reject(); //撤销下、刷新商品列表
- $("#addOrgan").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加供应商信息');
- $('#supplierFM').form('clear');
- });
-
- $("#addMember").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加会员信息');
- $('#supplierFM').form('clear');
- });
- $("#addCustomer").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加客户信息');
- $('#supplierFM').form('clear');
- });
- url = '/depotHead/addDepotHeadAndDetail';
-
-}
-
-//编辑信息
-function editDepotHead(index, status){
- if(status == "1" || status == "2") {
- $.messager.alert('编辑提示','已审核和已转的单据不能编辑!','warning');
- return;
- }
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata ='';
- if(Number(index).toString()=='NaN'){
- rowsdata=$.parseJSON(index);
- }else{
- rowsdata=$("#tableData").datagrid("getRows")[index];
- }
- $("#ProjectId").focus().val(rowsdata.projectid);
- var ProjectId=rowsdata.projectid;
- if(ProjectId!='') {
- initSystemData_person(ProjectId);
- initSelectInfo_person();
- }
- var TotalPrice = rowsdata.totalprice; //合计金额
- if(pageType === "skip") { //从订单跳转过来
- buildNumber(); //生成单据编号
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- $("#LinkNumber").val(rowsdata.number); //关联订单号
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- $("#DiscountLastMoney").val(TotalPrice); //优惠后金额
- $("#ChangeAmount").val(TotalPrice).attr("data-changeamount", TotalPrice);
- } else {
- $("#Number").val(rowsdata.number).attr("data-defaultNumber",rowsdata.number);
- $("#OperTime").val(rowsdata.opertimeStr);
- $("#LinkNumber").val(rowsdata.linknumber==undefined?"":rowsdata.linknumber); //关联订单号
- $("#AccountId").val(rowsdata.accountid); //账户Id
- $("#DiscountLastMoney").val(rowsdata.discountlastmoney==undefined?"0.00":rowsdata.discountlastmoney); //优惠后金额
- $("#ChangeAmount").val(rowsdata.changeamount).attr("data-changeamount", rowsdata.changeamount);
- }
- $('#OrganId').combobox('setValue', rowsdata.organid==undefined?'':rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#Remark").val(rowsdata.remark);
- $("#Discount").val(rowsdata.discount==undefined?"0":rowsdata.discount);
- $("#DiscountMoney").val(rowsdata.discountmoney==undefined?"0.00":rowsdata.discountmoney);
- $("#Debt").val(Number((rowsdata.discountlastmoney==undefined?'0.00':rowsdata.discountlastmoney-rowsdata.changeamount)).toFixed(2));
- $("#AccountDay").val(rowsdata.accountday==undefined?"":rowsdata.accountday); //结算天数
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于扣预付款
- $("#AllocationProjectId").val(rowsdata.allocationprojectid);
- oldNumber = rowsdata.number; //记录编辑前的单据编号
- oldId = rowsdata.id; //记录单据Id
- var editTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- depotHeadID = rowsdata.id;
- //采购入库、销售出库的多账户加载
- if(rowsdata.accountidlist!=undefined && rowsdata.accountmoneylist!=undefined){
- $("#AccountId").val("many"); //下拉框选中多账户
- var accountArr = rowsdata.accountidlist.split(",");
- var accountMoneyArr = rowsdata.accountmoneylist.split(",");
- accountMoneyArr = changeListFmtPlus(accountMoneyArr) //将数组单个金额中的数值转为正数
- $("#AccountId").attr("data-accountArr", JSON.stringify(accountArr)).attr("data-accountMoneyArr", JSON.stringify(accountMoneyArr)); //json数据存储
- $(".many-account-ico").show(); //显示多账户的ico图标
- }
-
- //采购入库、销售出库的费用数据加载
- if(rowsdata.othermoneylist &&rowsdata.othermoneyitem){
- $("#OtherMoney").val(rowsdata.othermoney==undefined?"0":rowsdata.othermoney); //采购费用、销售费用
- var itemArr = rowsdata.othermoneylist.split(",");
- var itemMoneyArr = rowsdata.othermoneyitem.split(",");
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
-
- initTableData_material("edit",TotalPrice); //商品列表
- reject(); //撤销下、刷新商品列表
- if(pageType === "skip") {
- url = '/depotHead/addDepotHeadAndDetail'; //如果是从订单跳转过来,则此处为新增的接口
- //jshjshjsh
- $("#depotHeadFM .datagrid-body").find("[field='DepotId']").click();
- } else {
- url = '/depotHead/updateDepotHeadAndDetail?id=' + rowsdata.id; //更新接口
- }
-}
-
-//查看信息
-function showDepotHead(index){
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var manyAccountMoney = 0; //多账户合计-零售
- $("#ProjectIdShow").text(rowsdata.projectName);
- $("#NumberShow").text(rowsdata.number);
- $("#OperTimeShow").text(rowsdata.opertimeStr);
- $('#OrganIdShow').text(rowsdata.organName==undefined?'':rowsdata.organName);
- $("#HandsPersonIdShow").text(rowsdata.handsPersonName);
- if(rowsdata.accountName && rowsdata.accountName!=undefined){
- $("#AccountIdShow").text(rowsdata.accountName); //结算账户
- } else {
- var accountArr = (rowsdata.accountidlist==undefined?"":rowsdata.accountidlist).split(","); //账户id列表
- var accountMoneyArr =(rowsdata.accountmoneylist==undefined?"":rowsdata.accountmoneylist).split(","); //账户金额列表
- var accountIdShow = "";
- for(var j =0;j 查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- depotHeadID = rowsdata.id;
- initTableData_material_show(TotalPrice); //商品列表-查看状态
-}
-
-//绑定操作事件
-function bindEvent(){
- showDepotHeadDetails(1,initPageSize); //初始化时自动查询
- //搜索处理
- $("#searchBtn").off("click").on("click",function(){
- showDepotHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh',
- {
- pageNumber:1,
- pageSize:initPageSize
- });
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- //$("#searchProjectId").val("");
- $("#searchState").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //检查单据编号是否存在
- function checkDepotHeadNumber() {
- var thisNumber = $.trim($("#Number").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(thisNumber.length > 0 &&( oldNumber.length ==0 || thisNumber != oldNumber))
- {
- $.ajax({
- type:"get",
- url: "/depotHead/checkIsNumberExist",
- dataType: "json",
- async : false,
- data: ({
- DepotHeadID : oldId,
- Number : thisNumber
- }),
- success: function (tipInfo)
- {
- flag = tipInfo;
- if(tipInfo)
- {
- $.messager.alert('提示','抱歉,该单据编号已经存在','warning');
- return;
- }
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','检查单据编号是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
- //保存信息
- /**
- * 2019-01-25
- * 我对这个方法的实现结果存在严重怀疑,决定重构
- * 有如下疑点:
- * 1、保存完主表,返回结果后,再发起请求去操作子表,如何保证事务的一致性(业务数据一致性)
- * 2、保存完主表后,再通过selectmax的方式去获取主表主键id完全就是看人品的不可靠的思路
- * 修改计划:
- * 2019-01-25修改零售出库相关操作
- * 修改方式,重写url,将主从表操作合并
- *
- *
- * **/
- $("#saveDepotHead").off("click").on("click",function(){
- if(!$('#depotHeadFM').form('validate')){
- return;
- }
- else {
- //如果初始编号被修改了,就要判断单据编号是否存在
- if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
- //调用查询单据编号是否重名的方法
- if(checkDepotHeadNumber()){
- return;
- }
- }
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择往来单位!','warning');
- return;
- }
- if (editIndex != undefined) {
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- //进行明细的校验
- if(depotHeadID ==0) {
- //新增模式下
- if (!CheckData("add")) {
- return;
- }
- }
- else {
- //编辑模式下
- if (!CheckData("edit")) {
- return;
- }
- }
- var OrganId = null, ProjectId = null,AllocationProjectId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val())-0;
- var TotalPrice = $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text();
- if($('#OrganId').length){
- OrganId = $('#OrganId').combobox('getValue');
- }
- var accountMoneyList = $("#AccountId").attr("data-accountmoneyarr"); //账户金额列表-多账户
- var accountMoneyArr;
- if(accountMoneyList) {
- accountMoneyList = accountMoneyList.replace("[","").replace("]","").toString();
- var reg=new RegExp("\"","g"); //创建正则RegExp对象
- accountMoneyList = accountMoneyList.replace(reg,""); //替换所有的双引号
- accountMoneyArr = accountMoneyList.split(","); //转为数组
- }
- //零售时候,可以从会员预付款中扣款
- var thisPayType = "现付";
- var SalesmanStr = "";
- var getAccountID = $.trim($("#AccountId").val());
- if($("#AccountId").val() === "many"){ //多账户
- getAccountID = null;
- }
- var infoStr=JSON.stringify({
- Type: listType,
- SubType: listSubType,
- ProjectId: ProjectId,
- AllocationProjectId: AllocationProjectId,
- DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
- Number: $.trim($("#Number").val()),
- LinkNumber: $.trim($("#LinkNumber").val()),
- OperTime: $("#OperTime").val(),
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Salesman: SalesmanStr, //销售人员
- AccountId: getAccountID,
- ChangeAmount: ChangeAmount, //付款/收款
- TotalPrice: TotalPrice, //合计
- PayType: thisPayType, //现付/预付款
- Remark: $.trim($("#Remark").val()),
- AccountIdList: $("#AccountId").attr("data-accountarr"), //账户列表-多账户
- AccountMoneyList: accountMoneyArr ? JSON.stringify(accountMoneyArr) : "", //账户金额列表-多账户
- Discount: $.trim($("#Discount").val()),
- DiscountMoney: $.trim($("#DiscountMoney").val()),
- DiscountLastMoney: $.trim($("#DiscountLastMoney").val()),
- OtherMoney: $.trim($("#OtherMoney").val()), //采购费用、销售费用
- OtherMoneyList: $("#OtherMoney").attr("data-itemarr"), //支出项目列表-涉及费用
- OtherMoneyItem: $("#OtherMoney").attr("data-itemmoneyarr"), //支出项目金额列表-涉及费用
- AccountDay: $("#AccountDay").val() //结算天数
- });
- /**
- * 零售出库,单独操作
- * */
- if(url.indexOf("/depotHead/addDepotHeadAndDetail")>=0){
- addDepotHeadAndDetail(url,infoStr);
- return;
- }else if(url.indexOf("/depotHead/updateDepotHeadAndDetail")>=0){
- updateDepotHeadAndDetail(url,infoStr,preTotalPrice);
- return;
- }
-
- }
- });
-
- //打印单据
- $("#printDepotHeadShow").off("click").on("click",function(){
- var tableString = $("#depotHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event){
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="State"||obj.id=="Number"))
- {
- $("#saveDepotHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber"||obj.id=="searchMaterial"))
- {
- $("#searchBtn").click();
- }
- });
-
- //优惠率输入框事件
- $("#Discount").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountNum = $(this).val();
- var discountMoney = (discountNum/100*totalPrice).toFixed(2);
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#DiscountMoney").val(discountMoney); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //优惠金额输入框事件
- $("#DiscountMoney").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountMoney = $(this).val();
- var discount = (discountMoney/totalPrice).toFixed(2)*100;
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#Discount").val(discount); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //付款、收款输入框事件
- $("#ChangeAmount").off("keyup").on("keyup",function(){
- var discountLastMoney = $("#DiscountLastMoney").val();
- var changeAmount = $(this).val();
- var debtMoney = (discountLastMoney - changeAmount).toFixed(2);
- $("#Debt").val(debtMoney); //本次欠款
- });
-
- //多账户结算窗口弹出事件
- function depotHeadAccountDlgFun(){
- $('#depotHeadAccountDlg').dialog('open').dialog('setTitle','
多账户结算');
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").remove(); //先移除输入栏目
- $("#accountMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#depotHeadAccountDlg .tabs-tmp .account-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#depotHeadAccountDlg .tabs-tmp tbody").html();
- var accountDlgHead = $("#depotHeadAccountDlg .account-head-tmp");
- accountDlgHead.after(contentTmp);
- }
-
- //获取账户信息
- function accountDlgFun() {
- var options = "";
- if(accountList !=null){
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- }
- $(".account-id-dlg").empty().append("").append(options);
- }
- }
- accountDlgFun(); //获取账户信息
- $("#depotHeadAccountDlg .tabs-tmp").hide(); //隐藏模板
-
- //账户金额输入框事件-多账户
- $("#depotHeadAccountDlg .account-dlg .account-money-dlg").off("keyup").on("keyup",function(){
- var totalAccoutNum = 0;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var eachAccountMoney = $(this).find(".account-money-dlg").val()-0;
- totalAccoutNum += eachAccountMoney;
- });
- $("#accountMoneyTotalDlg").text(totalAccoutNum);
- });
-
- //结算多账户列表的切换事件
- $("#depotHeadAccountDlg .account-dlg .account-id-dlg").off("change").on("change",function(){
- var selectAccount = $(this).children('option:selected').text();
- if(selectAccount === ""){
- var thisMoneyDom = $(this).closest(".account-content-tmp").find(".account-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text() - 0;
- $("#accountMoneyTotalDlg").text(accountMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //账户为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveDepotHeadAccountDlg").off("click").on("click", function(){
- //完成多账户的json数据存储
- var accountArr = []; //账户id数组
- var accountMoneyArr = []; //账户金额数组
- var errorIndex = -1;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var thisAccId = $(this).find(".account-id-dlg").val();
- var thisAccMoney = $(this).find(".account-money-dlg").val();
- if(!thisAccId && thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && !thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && thisAccMoney) {
- accountArr.push(thisAccId);
- accountMoneyArr.push(thisAccMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var discountLastMoneyNum =$("#DiscountLastMoney").val()-0; //优惠后金额
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text()-0; //本次付款或者收款
- if(accountMoneyTotal===0){
- $.messager.alert('错误提示',"请填写金额后保存",'warning');
- return;
- }
- if(accountArr.length && accountMoneyArr.length) {
- $("#AccountId").attr("data-accountArr",JSON.stringify(accountArr)).attr("data-accountMoneyArr",JSON.stringify(accountMoneyArr)); //json数据存储
- }
- $("#ChangeAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
- $("#Debt").val((discountLastMoneyNum-accountMoneyTotal).toFixed(2)); //本次欠款
- $("#depotHeadAccountDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#AccountId").attr("data-accountArr")){
- $("#depotHeadAccountDlg").dialog('close');
- }
- else {
- $("#depotHeadAccountDlg").dialog('close');
- $("#AccountId").val("").removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- }
- //多账户-取消按钮
- $("#cancelDepotHeadAccountDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //多账户-右上角的关闭按钮
- $("#depotHeadAccountDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
- }
- //点击多账户,弹出输入框
- $("#AccountId").off("change").on("change",function(){
- var selectText = $(this).children('option:selected').text();
- if(selectText === "多账户"){
- $("#ChangeAmount").prop("readonly","readonly");
- depotHeadAccountDlgFun();
- $(".many-account-ico").show(); //显示多账户小图标
- }
- else{
- $(this).removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- });
-
- //结算账户-多账户小图标-点击事件
- $(".many-account-ico").off("click").on("click",function(){
- depotHeadAccountDlgFun();
- //给弹窗赋值-多账户数据
- var accountArr = $("#AccountId").attr("data-accountArr");
- accountArr = JSON.parse(accountArr);
- var accountMoneyArr = $("#AccountId").attr("data-accountMoneyArr");
- accountMoneyArr = JSON.parse(accountMoneyArr);
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".account-id-dlg").val(accountArr[index]);
- $(this).find(".account-money-dlg").val(accountMoneyArr[index]);
- });
- $("#accountMoneyTotalDlg").text($("#ChangeAmount").val());
- });
-
- //点击采购费用、销售费用的事件
- $(".other-money-ico").off("click").on("click",function(){
- $('#otherMoneyDlg').dialog('open').dialog('setTitle','
'+ listSubType +'费用');
- $("#otherMoneyDlg .money-dlg .money-content-tmp").remove(); //先移除输入栏目
- $("#otherMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#otherMoneyDlg .tabs-tmp .money-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#otherMoneyDlg .tabs-tmp tbody").html();
- var moneyDlgHead = $("#otherMoneyDlg .money-head-tmp");
- moneyDlgHead.after(contentTmp);
- }
-
- //获取支出项目信息
- function moneyDlgFun() {
- var options = "";
- if(outItemList !=null){
- for(var i = 0 ;i < outItemList.length;i++) {
- var money = outItemList[i];
- options += '';
- }
- $(".money-id-dlg").empty().append("").append(options);
- }
- }
- moneyDlgFun(); //获取支出项目信息
- $("#otherMoneyDlg .tabs-tmp").hide(); //隐藏模板
-
- //支出项目的金额输入框事件
- $("#otherMoneyDlg .money-dlg .other-money-dlg").off("keyup").on("keyup",function(){
- var totalMoneyNum = 0;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var eachOtherMoney = $(this).find(".other-money-dlg").val()-0;
- totalMoneyNum += eachOtherMoney;
- });
- $("#otherMoneyTotalDlg").text(totalMoneyNum);
- });
-
- //支出项目列表的切换事件
- $("#otherMoneyDlg .money-dlg .money-id-dlg").off("change").on("change",function(){
- var selectItem = $(this).children('option:selected').text();
- if(selectItem === ""){
- var thisMoneyDom = $(this).closest(".money-content-tmp").find(".other-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text() - 0;
- $("#otherMoneyTotalDlg").text(otherMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //支出项目为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveOtherMoneyDlg").off("click").on("click", function(){
- //完成支出项目的json数据存储
- var itemArr = []; //支出项目id数组
- var itemMoneyArr = []; //支出项目金额数组
- var errorIndex = -1;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var thisId = $(this).find(".money-id-dlg").val();
- var thisMoney = $(this).find(".other-money-dlg").val();
- if(!thisId && thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && !thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && thisMoney) {
- itemArr.push(thisId);
- itemMoneyArr.push(thisMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text()-0; //合计金额
- if(otherMoneyTotal === 0){ //0的时候清空缓存数据
- $("#OtherMoney").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr");
- }
- if(itemArr.length && itemMoneyArr.length) {
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
- $("#OtherMoney").val(otherMoneyTotal); //给采购费用、销售费用赋值
- $("#otherMoneyDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#OtherMoney").attr("data-itemArr")){
- $("#otherMoneyDlg").dialog('close');
- }
- else {
- $("#otherMoneyDlg").dialog('close');
- $("#OtherMoney").val("").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr"); //将下拉置空并把缓存参数清空
- }
- }
- //费用-取消按钮
- $("#cancelOtherMoneyDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //费用-右上角的关闭按钮
- $("#otherMoneyDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
-
- //给弹窗赋值-采购费用、销售费用数据
- var itemArr = $("#OtherMoney").attr("data-itemArr");
- itemArr = JSON.parse(itemArr);
- var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr");
- itemMoneyArr = JSON.parse(itemMoneyArr);
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".money-id-dlg").val(itemArr[index]);
- if(itemMoneyArr[index]!="undefined"){
- $(this).find(".other-money-dlg").val(itemMoneyArr[index]);
- }
- });
- $("#otherMoneyTotalDlg").text($("#OtherMoney").val());
- });
-
- var supplierType = "供应商";
- //检查单位名称是否存在 ++ 重名无法提示问题需要跟进
- function checkSupplierName() {
- var supplierName = $.trim($("#supplier").val());
- var orgSupplier = "";
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(supplierName.length > 0 &&( orgSupplier.length ==0 || supplierName != orgSupplier))
- {
- $.ajax({
- type:"get",
- url: "/supplier/checkIsNameExist",
- dataType: "json",
- async : false,
- data: ({
- id : 0,
- name : supplierName
- }),
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data && res.data.status) {
- flag = res.data.status;
- if (flag) {
- $.messager.alert('提示', '单位名称已经存在', 'info');
- return;
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('提示','检查单位名称是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
-
- //保存供应商信息
- $("#saveSupplier").off("click").on("click",function() {
- if(validateForm("supplierFM")) {
- return;
- }
- if(checkSupplierName()){
- return;
- }
- var reg = /^([0-9])+$/;
- var phonenum = $.trim($("#phonenum").val());
- if(phonenum.length>0 && !reg.test(phonenum))
- {
- $.messager.alert('提示','电话号码只能是数字','info');
- $("#phonenum").val("").focus();
- return;
- }
- var beginNeedGet = $.trim($("#BeginNeedGet").val());
- var beginNeedPay = $.trim($("#BeginNeedPay").val());
- if(beginNeedGet && beginNeedPay) {
- $.messager.alert('提示','期初应收和期初应付不能同时输入','info');
- return;
- }
- var url = '/supplier/add';
- var supObj = $("#supplierFM").serializeObject();
- supObj.type = supplierType;
- supObj.enabled = 1;
- $.ajax({
- url: url,
- type:"post",
- dataType: "json",
- data:{
- info: JSON.stringify(supObj)
- },
- success: function(res) {
- if (res) {
- $('#supplierDlg').dialog('close');
- initSupplier(); //刷新供应商
- }
- }
- });
- });
-}
-
-function showDepotHeadDetails(pageNo,pageSize){
- var materialParam = $.trim($("#searchMaterial").val());
- var beginTime = $.trim($("#searchBeginTime").val());
- var endTime = $.trim($("#searchEndTime").val());
- if(beginTime) {
- beginTime = beginTime + ' 00:00:00';
- }
- if(endTime) {
- endTime = endTime + ' 23:59:59';
- }
- $.ajax({
- type: "get",
- url: "/depotHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- subType: listSubType,
- state: $.trim($("#searchState").val()),
- number: $.trim($("#searchNumber").val()),
- beginTime: beginTime,
- endTime: endTime,
- materialParam: materialParam,
- depotIds: depotString
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#depotHeadFM .datagrid-body");
- var footer =$("#depotHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
- //点击商品下拉框,自动加载数量、单价、金额
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //点击库存文本框,字段计算库存
- body.find("[field='Stock']").find(input).off("click").on("click",function(){
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- var monthTime = getNowFormatMonth();
- if(depotId && mId){
- var ratio = body.find("[field='Unit']").find(input).attr("data-ratio");
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //在新增的时候,这个ratio有值;在编辑的时候,这个ratio为undefined
- var type = "click"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratio, type);
- }
- else{
- body.find("[field='Stock']").find(input).val(0).attr("data-stock",0); //加载库存数据
- }
- });
- //修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计
- body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber =$(this).val()-0; //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
-
- });
- //修改单价,自动计算金额和合计
- body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice =$(this).val()-0; //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击单价,自动提示参考价格列表
- body.find("[field='UnitPrice']").find(input).off("click").on("click",function(){
- var self = this;
- var mValue = body.find("[field='MaterialId'] .combo-value").attr("value"); //获取选中的商品id
- if(!mValue) {
- return;
- }
- else {
- return;
- }
- });
- //修改含税单价,自动计算单价、金额、税额、价税合计和合计
- body.find("[field='TaxUnitPrice']").find(input).off("keyup").on("keyup",function(){
- var TaxUnitPrice =$(this).val()-0; //含税单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var UnitPrice = TaxUnitPrice/(1+taxRate/100); //计算单价
- body.find("[field='UnitPrice']").find(input).val((UnitPrice).toFixed(2)); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改金额,自动计算单价、税额、价税合计和合计
- body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var AllPrice =$(this).val()-0; //金额
- var UnitPrice = (AllPrice/OperNumber).toFixed(2);
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税率,自动计算含税单价、税额、价税合计和合计
- body.find("[field='TaxRate']").find(input).off("keyup").on("keyup",function(){
- var taxRate =$(this).val()-0; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税额,自动计算税率、含税单价、价税合计和合计
- body.find("[field='TaxMoney']").find(input).off("keyup").on("keyup",function(){
- var taxMoney =$(this).val()-0; //税额
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = taxMoney/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改价税合计,自动计算税率、含税单价、税额和合计
- body.find("[field='TaxLastMoney']").find(input).off("keyup").on("keyup",function(){
- var taxLastMoney =$(this).val()-0; //价税合计
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = (taxLastMoney-AllPrice)/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
-
- //加载税率
- if(thisTaxRate) {
- body.find("[field='TaxRate']").find(input).val(thisTaxRate);
- }
- else {
- body.find("[field='TaxRate']").find(input).val(0); //默认为0
- }
-
- //在商品类型加载 组装件、普通子件
- var mType = body.find("[field='MType']");
- var rowListLength = mType.find(input).closest(".datagrid-row").attr("datagrid-row-index");
- var mTypeValue = "组合件";
- if(rowListLength > 0){
- mTypeValue = "普通子件";
- }
- },500);
-}
-
-//结束编辑
-function endEditing() {
- if (editIndex == undefined) { return true }
- if ($('#materialData').datagrid('validateRow', editIndex)) {
- //仓库信息
- var edDepot = $('#materialData').datagrid('getEditor', {index:editIndex,field:'DepotId'});
- var DepotName = $(edDepot.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName;
- //商品信息
- var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'});
- var MaterialName = $(edMaterial.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName;
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#materialData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append(){
- if (endEditing()) {
- $('#materialData').datagrid('appendRow', {DepotId:defDepotId});
- editIndex = $('#materialData').datagrid('getRows').length - 1;
- $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function batchDel(){
- /**
- * 重写一下删除的逻辑
- * 获取所有选中行,直接从列表中移除
- * 点击保存时,将需要后台删除的数据提交到服务器
- * **/
- /**
- * create by: qiankunpingtai
- * create time: 2019/3/20 16:26
- * description:
- * 这个地方比较坑的,花了一个多小时才搞明白为什么
- * 1、删除之前必须先调用endEditing结束编辑
- * 2、如果只是调用endEditing结束编辑那么正在编辑行的被选中状态会被去掉
- * 所以要在调用endEditing先获取选中的行
- */
- //如果编辑的行一开始是选中状态,结束编辑后仍然是选中状态
- var row = $('#materialData').datagrid('getChecked');
- if (endEditing()) {
- if (row.length == 0) {
- $.messager.alert('删除提示', '没有记录被选中!', 'info');
- return;
- }
- if (row.length > 0) {
- $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条单据信息吗?', function (r) {
- if (r) {
- for (var i = 0; i < row.length; i++) {
- $('#materialData').datagrid('deleteRow', $('#materialData').datagrid("getRowIndex", row[i]));
- }
- }
- });
- }
- }
-}
-function removeit(){
- if (editIndex == undefined) { return }
- $('#materialData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#materialData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData(type) {
- var change = $('#materialData').datagrid('getChanges').length;
- if(type =="add" && !change) {
- $.messager.alert('提示','请输入明细信息!','warning');
- return false;
- }
- var row = $('#materialData').datagrid('getRows');
- if(!row.length){
- $.messager.alert('提示',"请输入明细信息!",'info');
- return false;
- }
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if (row[i].DepotId == "" || row[i].MaterialId == "" || row[i].OperNumber == "" || row[i].UnitPrice === "" || row[i].AllPrice === "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-
-
-/**
- * 新增单据主表及单据子表
- * */
-function addDepotHeadAndDetail(url,infoStr){
- var inserted = null;
- if(pageType === "skip") {
- inserted = $("#materialData").datagrid('getChanges', "updated");
- } else {
- inserted = $("#materialData").datagrid('getChanges', "inserted");
- }
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated)
- }),
- success: function (tipInfo){
-
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
-
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
-
-
- });
-}
-/**
- * 修改单据主表及单据子表
- * */
-function updateDepotHeadAndDetail(url,infoStr,preTotalPrice){
- var inserted = $("#materialData").datagrid('getChanges', "inserted");
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- id:url.substring(url.lastIndexOf("?id=")+4,url.length),
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- preTotalPrice:preTotalPrice
- }),
- success: function (tipInfo){
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
- if (endEditing()) {
- $('#materialData').datagrid('acceptChanges');
- }
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-
-
-
diff --git a/erp_web/js/pages/materials/other_out_list.js b/erp_web/js/pages/materials/other_out_list.js
deleted file mode 100644
index d1ca7f2a..00000000
--- a/erp_web/js/pages/materials/other_out_list.js
+++ /dev/null
@@ -1,2371 +0,0 @@
-//初始化界面
-var defDepotId = null;
-var kid = sessionStorage.getItem("userId");
-var pageType = getUrlParam('t'); //获取页面类型传值
-var depotList = null;
-var depotID = null;
-var supplierList = null;
-var supplierID = null;
-var personList = null;
-var personID = null;
-var ProjectSearch=null;
-var userBusinessList=null;
-var userdepot=null;
-var url;
-var depotHeadID = 0;
-var preTotalPrice = 0; //前一次加载的金额
-var orgDepotHead = "";
-var editIndex = undefined;
-/**默认编号有意义吗,不如空着吧*/
-var orgDefaultId=''; //单位默认编号
-var orgDefaultList; //存储查询出来的会员列表
-var accountList; //账户列表
-var outItemList; //支出项目列表
-var thisTaxRate = 0; //当前税率,选择供应商或者客户的时候设置
-var oldNumber = ""; //编辑前的单据编号
-var oldId = 0; //编辑前的单据Id
-var otherColumns = true; //明细中的‘别名’列是否显示
-var btnEnableList = getBtnStr(); //获取按钮的权限
-var mPropertyList = ""; //商品属性列表
-var defaultAccountId = 0; //默认账户id
-//改变宽度和高度
-$("#searchPanel").panel({width:webW-2});
-$("#tablePanel").panel({width:webW-2});
-var listTitle = "其它出库列表"; //单据标题
-var depotString = "|"; //店铺id列表
-var listType = "出库";//入库 出库
-var listSubType = "其它"; //采购 销售等
-var payTypeTitle = "隐藏"; //付款 收款
-var organUrl = "/supplier/findBySelect_cus?UBType=UserCustomer&UBKeyId=" + kid; //组织数据接口地址
-var amountNum ="QTCK";//单据编号开头字符
-$(function(){
- //初始化系统基础信息
- initSystemData_UB();
- initSelectInfo_UB();
- initSystemData_depot();
- initSelectInfo_depot();
- initSystemData_person();
- initSelectInfo_person();
- initSystemData_account();
- initSelectInfo_account();
- initSupplier(); //供应商
- initSalesman(); //销售人员
- initOutItemList(); //初始化支出项目
- initMProperty(); //初始化商品属性
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
-});
-//初始化系统基础信息
-function initSystemData_UB(){
- $.ajax({
- type:"get",
- url: "/userBusiness/getBasicData",
- data: ({
- KeyId:kid,
- Type:"UserDepot"
- }),
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if (res && res.code === 200) {
- userBusinessList = res.data.userBusinessList;
- }
- else {
- userBusinessList = null;
- }
- }
- });
-
-}
-//初始化页面选项卡
-function initSelectInfo_UB(){
-
- if(userBusinessList !=null)
- {
- if(userBusinessList.length>0)
- {
- //用户对应的仓库列表 [1][2][3]...
- userdepot =userBusinessList[0].value;
- }
- }
-}
-
-
-//初始化系统基础信息
-function initSystemData_depot(){
- $.ajax({
- type:"get",
- url: "/depot/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200){
- depotList = res.data;
- } else {
- $.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error');
- return;
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_depot(){
- var options = "";
-
- if(depotList !=null)
- {
- options = "";
- for(var i = 0 ;i < depotList.length;i++)
- {
- var depot = depotList[i];
-
- if(userdepot!=null)
- {
- if(userdepot.indexOf("["+depot.id+"]")!=-1)
- {
- if(depot.isDefault){
- defDepotId = depot.id;
- }
- options += '';
- depotString = depotString + depot.id + ",";
- }
- }
- if(depot.type === 1){
- depotString = depotString + depot.id + ",";
- }
- }
- depotString = depotString.substring(1, depotString.length-1);
- $("#ProjectId").empty().append(options);
- $("#AllocationProjectId").empty().append(options);
- $("#searchProjectId").empty().append('').append(options);
- }
-}
-
-//初始化供应商、客户、散户信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onLoadSuccess: function(res) {
- var data = $(this).combobox('getData');
- for(var i = 0; i<= data.length; i++){
- if(data && data[i] && data[i].supplier === "非会员"){
- orgDefaultId = data[i].id;
- }
- }
- },
- onSelect: function(rec){
- $.ajax({
- type:"get",
- url: "/supplier/findById",
- data: {
- supplierId: rec.id
- },
- dataType: "json",
- success: function (res){
- if(res && res.code === 200) {
- if(res.data && res.data[0]){
- thisTaxRate = res.data[0].taxRate; //设置当前的税率
- }
- }
- },
- error:function(){
-
- }
- });
- }
- });
-}
-
-//初始化销售人员
-function initSalesman(){
- $('#Salesman').combobox({
- url: "/person/getPersonByNumType?type=1",
- valueField:'id',
- textField:'name',
- multiple: true
- });
-}
-
-//初始化收入项目列表
-function initOutItemList(){
- $.ajax({
- type:"get",
- url: "/inOutItem/findBySelect?type=out",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res){
- if(res){
- outItemList = res;
- }
- },
- error:function(){
-
- }
- });
-}
-
-//初始化商品属性
-function initMProperty(){
- $.ajax({
- type: "get",
- url: "/materialProperty/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- name: ""
- }),
- currentPage: 1,
- pageSize: 100
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- var thisRows = res.data.page.rows;
- for (var i = 0; i < thisRows.length; i++) {
- if (thisRows[i].enabled) {
- mPropertyList += thisRows[i].nativename + ",";
- }
- }
- if (mPropertyList) {
- mPropertyList = mPropertyList.substring(0, mPropertyList.length - 1);
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化系统基础信息
-function initSystemData_person(){
- $.ajax({
- type:"get",
- url: "/person/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- personList = res.data.personList;
- }
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_person(){
- var options1 = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="仓管员")
- {
- options1 += '';
- }
- }
- $("#HandsPersonId").empty().append(options1);
- }
-}
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null){
- options = "";
- options += "";
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- if(account.isdefault) {
- defaultAccountId = account.id; //给账户赋值默认id
- }
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#depotHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- if(pageType === "skip") {
- var oldRowInfo = sessionStorage.getItem("rowInfo");
- editDepotHead(oldRowInfo); //自动弹出编辑框,带缓存数据
- }
- var hideType = undefined;
- var isHiddenStatus = true;
- if(payTypeTitle === "隐藏"){
- hideType = true; //隐藏当前列
- }
- var tableToolBar = [
- {
- id:'addDepotHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addDepotHead();
- }
- },
- {
- id:'deleteDepotHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteDepotHead();
- }
- }
- ];
- //如果允许的按钮列表中存在就显示,3-代表审核|反审核的权限
- if(btnEnableList && btnEnableList.indexOf(3)>-1){
- isHiddenStatus = false; //显示
- tableToolBar.push({
- id:'okDepotHead',
- text:'审核',
- iconCls:'icon-ok',
- handler:function() {
- setStatusFun();
- }
- },
- {
- id:'undoDepotHead',
- text:'反审核',
- iconCls:'icon-undo',
- handler:function() {
- setUnStatusFun();
- }
- });
- }
- else {
- isHiddenStatus = true; //隐藏
- }
- var isShowLastMoneyColumn = true; //是否显示优惠后金额和价税合计,true为隐藏,false为显示
- var isShowOrganNameColumn = false; //是否显示供应商、客户等信息,true为隐藏,false为显示
- var organNameTitle ="客户名称"; //组织名称标题
- var opWidth = 90; //操作宽度
- var opTitle = ""; //跳转按钮的标题
- $('#tableData').datagrid({
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: true,
- //交替出现背景
- striped : true,
- pageSize: 10,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:opWidth,
- formatter:function(value, rec,index) {
- var str = '';
- var orgId = rec.organid? rec.organid:0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
- { title: '单据编号',field: 'number',width:135, formatter:function (value,rec) {
- if(rec.linknumber) {
- return value + "[转]";
- } else {
- return value;
- }
- }
- },
- { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
- if(value) {
- return value.replace(",",",");
- }
- }
- },
- { title: '单据日期',field: 'opertimeStr',width:130},
- { title: '操作员',field: 'operpersonname',width:60},
- { title: '金额合计',field: 'totalprice',width:60},
- { title: '含税合计',field: 'totaltaxlastmoney',hidden:isShowLastMoneyColumn,width:60,formatter:function(value,rec){
- return (rec.discountmoney + rec.discountlastmoney).toFixed(2);
- }
- },
- { title: '优惠后金额',field: 'discountlastmoney',hidden:isShowLastMoneyColumn,width:80},
- { title: payTypeTitle,field: 'changeamount',width:50,hidden:hideType},
- { title: '状态',field: 'status',hidden:isHiddenStatus, width:70,align:"center",formatter:function(value){
- if(value === "0") {
- return "未审核";
- } else if(value === "1") {
- return "已审核";
- } else if(value === "2") {
- }
- }
- }
- ]],
- toolbar:tableToolBar,
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//查找库存的方法
-function findStockNumById(depotId, mId, monthTime, body, input, ratio, type){
- var thisRatio = 1; //比例
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (rec) {
- if(rec && rec.code === 200 && rec.data && rec.data[0]) {
- var loadRatio = 1; //在单位输入框上面加载比例字段
- if(rec.data[0].unit) { //如果存在计量单位信息
- loadRatio = 1;
- }
- else{
- var unitName = rec.data[0].unitName;
- if(unitName) {
- thisRatio = unitName.substring(unitName.indexOf(":")+1).replace(")","");
- unitName = unitName.substring(0, unitName.indexOf("("));
- }
- }
- //查询库存
- $.ajax({
- type: "get",
- url: '/depotItem/findStockNumById',
- data:{
- projectId: depotId,
- materialId: mId
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if (res.data && res.data.page && res.data.page[0]) {
- var thisStock = res.data.page[0].thisSum;
- if (type == "select") { //选择下拉框的时候
- if (ratio != undefined && ratio != 1) {
- loadRatio = ratio;
- }
- }
- else if (type == "click") { //点击库存的时候
- if (ratio != undefined) {
- loadRatio = ratio;
- }
- }
- thisStock = (thisStock / loadRatio).toFixed(2);
- body.find("[field='Stock']").find(input).val(thisStock).attr("data-stock", res.data.page[0].thisSum); //加载库存数据
- }
- else {
- body.find("[field='Stock']").find(input).val(0).attr("data-stock", 0); //加载库存数据
- }
- body.find("[field='Stock']").find(input).prop("readonly", "readonly"); //设置库存数据为只读
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
- }
- },
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- }
- });
-}
-//优惠率、合计的统计方法
-function statisticsFun(body,UnitPrice,OperNumber,footer,taxRate){
- var TotalPrice = 0;
- var taxLastMoneyTotal = 0;
- //金额的合计
- body.find("[field='AllPrice']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + UnitPrice*OperNumber;
- footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); //金额的合计
- //价税合计的总计
- body.find("[field='TaxLastMoney']").each(function(){
- if($(this).find("div").text()!==""){
- taxLastMoneyTotal = taxLastMoneyTotal + (parseFloat($(this).find("div").text().toString())-0);
- }
- });
- taxLastMoneyTotal = taxLastMoneyTotal + (UnitPrice*OperNumber*(1+taxRate/100));
- footer.find("[field='TaxLastMoney']").find("div").text((taxLastMoneyTotal).toFixed(2)); //价税合计的页脚总计
- var discount = $("#Discount").val(); //优惠率
- var discountMoney = (taxLastMoneyTotal*discount/100).toFixed(2);
- $("#DiscountMoney").val(discountMoney);//优惠金额
- var discountLastMoney = (taxLastMoneyTotal*(1-discount/100)).toFixed(2)
- $("#DiscountLastMoney").val(discountLastMoney);//优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
-
-}
-//初始化表格数据-商品列表-编辑状态
-function initTableData_material(type,TotalPrice){
- var body,footer,input; //定义表格和文本框
- var ratio = 1; //比例-品名专用
- var ratioDepot = 1; //比例-仓库用
- var monthTime = getNowFormatMonth();
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var depotHeadName = ""; //仓库名称
- var depotUrl = ""; //仓库接口地址
- var depotTextField = ""; //仓库下拉名称
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var anotherDepotUrl = ""; //对方仓库接口地址
- var anotherDepotTextField = "";
- depotHeadName = "仓库名称";
- depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- depotTextField = "depotName";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialData').datagrid({
- height:245,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: '商品类型',field: 'MType',editor:'validatebox',hidden:isShowMaterialTypeColumn,width:80},
- { title: depotHeadName, field: 'DepotId', editor: 'validatebox', width: 90,
- formatter: function (value, row, index) {
- return row.DepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: depotTextField,
- method: 'get',
- url: depotUrl,
- onSelect:function(rec){
- var depotId = rec.id;
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- if(mId){
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratioDepot, type);
- }
- }
- }
- }
- },
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialId',width:230,
- formatter:function(value,row,index){
- return row.MaterialName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'MaterialName',
- method:'get',
- url: "/material/findBySelect",
- panelWidth: 300, //下拉框的宽度
- //全面模糊匹配,过滤字段
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onBeforeLoad: function(param){
- param.mpList = mPropertyList; //商品属性
- },
- onSelect:function(rec){
- if(rec) {
- var mId = rec.Id;
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (res) {
- if(res && res.code === 200 && res.data && res.data[0]) {
- var retailPrice = res.data[0].retailprice-0; //零售价格
- var presetPriceOne = res.data[0].presetpriceone-0; //预计采购价
- var presetPriceTwo = res.data[0].presetpricetwo-0; //批发价
- var firstInUnit = res.data[0].firstinunit; //首选入库单位
- var firstOutUnit = res.data[0].firstoutunit; //首选出库单位
- var basicPresetPriceOne = ""; //多单位-入库-基础价格
- var basicPresetPriceTwo = ""; //多单位-出库-基础价格
- var retailPriceOne = ""; //多单位-入库-零售价格
- var otherPresetPriceOne = ""; //多单位-入库-其他价格
- var otherPresetPriceTwo = ""; //多单位-出库-其他价格
- var retailPriceTwo = ""; //多单位-出库-零售价格
- var basicUnit = ""; //基础单位
- var otherUnit = ""; //其他单位
- if(!res.data[0].unit){
- var ps = res.data[0].pricestrategy;
- var psObj = JSON.parse(ps);
- basicPresetPriceOne = psObj[0].basic.PresetPriceOne-0;
- basicPresetPriceTwo = psObj[0].basic.PresetPriceTwo-0;
- retailPriceOne = psObj[0].basic.RetailPrice-0;
- otherPresetPriceOne = psObj[1].other.PresetPriceOne-0;
- otherPresetPriceTwo = psObj[1].other.PresetPriceTwo-0;
- retailPriceTwo = psObj[1].other.RetailPrice-0;
- basicUnit = psObj[0].basic.Unit;
- otherUnit = psObj[1].other.Unit;
- }
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- if(res.data[0].unit){ //如果存在计量单位信息
- ratio = 1; //重置比例为1
- body.find("[field='Unit']").find(input).val(res.data[0].unit); //设置-计量单位信息
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- body.find("[field='Unit']").find(input).off("click"); //移除点击事件
- body.find("[field='Unit']").find(input).attr("data-ratio",ratio); //修改比例缓存信息
- }
- else {
- var unitName = res.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- var loadRatio = 1; //在单位输入框上面加载比例字段
- body.find("[field='Unit']").find(input).val(unitSetInput).attr("data-ratio", loadRatio); //设置-首选单位
-
- body.find("[field='Unit']").find(input).off("click").on("click",function(){
- if(basicUnit && otherUnit) {
- var self = this;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- " + basicUnit + "
";
- temp +="- " + otherUnit + "
";
- temp +="
";
- temp +="
";
- if($('.unit-list').length){
- $('.unit-list').remove(); //如果存在计量单位列表先移除
- }
- else {
- $(self).after(temp); //加载列表信息
- }
- //计量单位列表的单击事件
- $('.unit-list ul li').off("click").on("click",function(){
- var unit = $(this).text();
- var thisRatio = $(this).attr("data-ratio"); //获取比例
- $(self).val(unit).attr("data-ratio", thisRatio);
- $(self).keyup(); //模拟键盘操作
- $('.unit-list').remove(); //移除计量单位列表
- var stock = body.find("[field='Stock']").find(input).attr("data-stock"); //从缓存中取值
- var type = $(this).attr("data-type");
- var UnitPrice = 0;
- if(type === "basic"){
- UnitPrice = basicPresetPriceTwo;
- body.find("[field='Stock']").find(input).val(stock); //修改库存
- }
- else if(type === "other"){
- UnitPrice = otherPresetPriceTwo;
- body.find("[field='Stock']").find(input).val((stock/ratio).toFixed(2)); //修改库存
- }
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //获取数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击空白处移除计量单位列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.unit-list').remove(); //移除计量单位列表
- });
- }
- });
- }
- var detailPrice = 0; //明细列表-单价
- if(res.data[0].unit) { //如果存在计量单位信息
- detailPrice = presetPriceTwo;
- }
- else {
- if(firstOutUnit==basicUnit) {
- detailPrice = basicPresetPriceTwo;
- }
- else if(firstOutUnit==otherUnit){
- detailPrice = otherPresetPriceTwo;
- }
- }
- body.find("[field='OperNumber']").find(input).val(1); //数量初始化为1
- //单价和总价赋值
- if(!detailPrice) {
- detailPrice = 0;
- }
- body.find("[field='UnitPrice']").find(input).val(detailPrice);
- body.find("[field='AllPrice']").find(input).val(detailPrice);
- var taxRate = body.find("[field='TaxRate']").find(input).val()-0; //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((detailPrice*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,detailPrice,1,footer,taxRate);
-
- //查询库存信息
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- if(depotId) {
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, loadRatio, type);
- }
- }
- },
- error: function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- }
- });
- }
- }
- }
- }
- },
- { title: '库存',field: 'Stock',editor:'validatebox',width:70},
- { title: anotherDepotHeadName, field: 'AnotherDepotId',editor:'validatebox',hidden:isShowAnotherDepot,width:90,
- formatter: function (value, row, index) {
- return row.AnotherDepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: anotherDepotTextField,
- method: 'get',
- url: anotherDepotUrl
- }
- }
- },
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率(%)',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batchDel(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = 0;
- var TaxLastMoney = 0;
- var DiscountMoney = $("#DiscountMoney").val()-0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoney").val()-0; //优惠后金额
- if(type === "edit") {
- AllPrice = TotalPrice;
- TaxLastMoney = DiscountMoney + DiscountLastMoney;
- }
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": TaxLastMoney
- });
- data.footer = array;
- $("#materialData").datagrid('loadData',data);
- //如果是订单跳转到采购或销售
- if(pageType === "skip") {
- var skipList = $("#depotHeadFM .datagrid-body tr");
- //逐条自动点击每行数据
- skipList.each(function (i) {
- setTimeout(function () {
- skipList.eq(i).find("[field='Stock']").click();
- },(i+1)*1000);
- });
- }
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//初始化表格数据-商品列表-查看状态
-function initTableData_material_show(TotalPrice){
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var depotHeadName = ""; //仓库的列的标题
- depotHeadName = "仓库名称";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialDataShow').datagrid({
- height:245,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- onClickRow: onClickRow,
- columns:[[
- { title: '商品类型',field: 'MType',width:80, hidden:isShowMaterialTypeColumn},
- { title: depotHeadName,field: 'DepotName',editor:'validatebox',width:90},
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialName',width:230},
- { title: anotherDepotHeadName,field: 'AnotherDepotName',hidden:isShowAnotherDepot,width:90},
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validattebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = TotalPrice;
- var DiscountMoney = $("#DiscountMoneyShow").text() - 0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoneyShow").text() - 0; //优惠后金额
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": DiscountMoney + DiscountLastMoney
- });
- data.footer = array;
- $("#materialDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showDepotHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除单据信息
-function deleteDepotHead(depotHeadID, thisOrganId, totalPrice, status){
- if(status == "1" || status == "2") {
- $.messager.alert('删除提示','已审核和已转的单据不能删除!','warning');
- return;
- }
- $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
- if (r) {
- $.ajax({
- type:"post",
- // url: "/depotHead/" + depotHeadID + "/delete",
- url: "/depotHead/deleteDepotHeadAndDetail",
- dataType: "json",
- data:{
- id: depotHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
- return;
- }
- });
-
- }
- });
-}
-
-//订单转采购或销售
-function skipDepotHead(index, status){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- if(status == "0" || status == "2") {
- $.messager.alert('提示','未审核和已转的单据禁止操作!','warning');
- } else {
- sessionStorage.setItem("rowInfo", JSON.stringify(rowsdata)); //将单据信息存入缓存中
- }
-}
-
-//批量删除单据信息
-function batDeleteDepotHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条单据信息吗?',function(r)
- {
- if (r) {
- var ids = "";
- for (var i = 0; i < row.length; i++) {
- if (i == row.length - 1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- if (ids) {
- //批量删除
- $.ajax({
- type: "post",
- // url: "/depotHead/batchDelete",
- url: "/depotHead/batchDeleteDepotHeadAndDetail",
- dataType: "json",
- async: false,
- data: ({
- ids: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除单据信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('删除提示','没有能删除的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量审核
-function setStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('审核确认','确定要审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: "1",
- depotHeadIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('审核提示', '审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('审核提示','审核信息异常,请稍后再试!','error');
- return;
- }
- });
- } else {
- $.messager.alert('审核提示','没有能审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量反审核
-function setUnStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('反审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('反审核确认','确定要反审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type: "post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async: false,
- data: ({
- status: "0",
- depotHeadIDs: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('反审核提示', '反审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('反审核提示', '反审核信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('反审核提示','没有能反审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//生成单据编号
-function buildNumber() {
- $.ajax({
- type: "get",
- url: "/depotHead/buildNumber",
- success:function(res){
- if(res && res.code === 200){
- var obj = res.data;
- var defaultNumber = obj.DefaultNumber;
- var newNumber = amountNum + defaultNumber;
- $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
- }
- },
- error:function(){
- $.messager.alert('提示','生成单据编号失败!','error');
- }
- });
-}
-
-//新增信息
-function addDepotHead(){
- $('#depotHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- buildNumber(); //生成单据编号
- //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为0
- $("#Discount").val(0);
- $("#DiscountMoney").val(0);
- $("#DiscountLastMoney").val(0);
- $("#ChangeAmount").val(0);
- $("#Debt").val(0);
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- var addTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgDepotHead = "";
- depotHeadID = 0;
- initTableData_material("add"); //商品列表
- reject(); //撤销下、刷新商品列表
- $("#addOrgan").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加供应商信息');
- $('#supplierFM').form('clear');
- });
-
- $("#addMember").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加会员信息');
- $('#supplierFM').form('clear');
- });
- $("#addCustomer").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加客户信息');
- $('#supplierFM').form('clear');
- });
- url = '/depotHead/addDepotHeadAndDetail';
-
-}
-
-//编辑信息
-function editDepotHead(index, status){
- if(status == "1" || status == "2") {
- $.messager.alert('编辑提示','已审核和已转的单据不能编辑!','warning');
- return;
- }
- //获取当前行
- var rowsdata ='';
- if(Number(index).toString()=='NaN'){
- rowsdata=$.parseJSON(index);
- }else{
- rowsdata=$("#tableData").datagrid("getRows")[index];
- }
- $("#ProjectId").focus().val(rowsdata.projectid);
- var ProjectId=rowsdata.projectid;
- if(ProjectId!='') {
- initSystemData_person(ProjectId);
- initSelectInfo_person();
- }
- var TotalPrice = rowsdata.totalprice; //合计金额
- if(pageType === "skip") { //从订单跳转过来
- buildNumber(); //生成单据编号
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- $("#LinkNumber").val(rowsdata.number); //关联订单号
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- $("#DiscountLastMoney").val(TotalPrice); //优惠后金额
- $("#ChangeAmount").val(TotalPrice).attr("data-changeamount", TotalPrice);
- } else {
- $("#Number").val(rowsdata.number).attr("data-defaultNumber",rowsdata.number);
- $("#OperTime").val(rowsdata.opertimeStr);
- $("#LinkNumber").val(rowsdata.linknumber==undefined?"":rowsdata.linknumber); //关联订单号
- $("#AccountId").val(rowsdata.accountid); //账户Id
- $("#DiscountLastMoney").val(rowsdata.discountlastmoney==undefined?"0.00":rowsdata.discountlastmoney); //优惠后金额
- $("#ChangeAmount").val(rowsdata.changeamount).attr("data-changeamount", rowsdata.changeamount);
- }
- $('#OrganId').combobox('setValue', rowsdata.organid==undefined?'':rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#Remark").val(rowsdata.remark);
- $("#Discount").val(rowsdata.discount==undefined?"0":rowsdata.discount);
- $("#DiscountMoney").val(rowsdata.discountmoney==undefined?"0.00":rowsdata.discountmoney);
- $("#Debt").val(Number((rowsdata.discountlastmoney==undefined?'0.00':rowsdata.discountlastmoney-rowsdata.changeamount)).toFixed(2));
- $("#AccountDay").val(rowsdata.accountday==undefined?"":rowsdata.accountday); //结算天数
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于扣预付款
- $("#AllocationProjectId").val(rowsdata.allocationprojectid);
- oldNumber = rowsdata.number; //记录编辑前的单据编号
- oldId = rowsdata.id; //记录单据Id
- var editTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- depotHeadID = rowsdata.id;
- //采购入库、销售出库的多账户加载
- if(rowsdata.accountidlist!=undefined && rowsdata.accountmoneylist!=undefined){
- $("#AccountId").val("many"); //下拉框选中多账户
- var accountArr = rowsdata.accountidlist.split(",");
- var accountMoneyArr = rowsdata.accountmoneylist.split(",");
- accountMoneyArr = changeListFmtPlus(accountMoneyArr) //将数组单个金额中的数值转为正数
- $("#AccountId").attr("data-accountArr", JSON.stringify(accountArr)).attr("data-accountMoneyArr", JSON.stringify(accountMoneyArr)); //json数据存储
- $(".many-account-ico").show(); //显示多账户的ico图标
- }
-
- //采购入库、销售出库的费用数据加载
- if(rowsdata.othermoneylist &&rowsdata.othermoneyitem){
- $("#OtherMoney").val(rowsdata.othermoney==undefined?"0":rowsdata.othermoney); //采购费用、销售费用
- var itemArr = rowsdata.othermoneylist.split(",");
- var itemMoneyArr = rowsdata.othermoneyitem.split(",");
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
-
- initTableData_material("edit",TotalPrice); //商品列表
- reject(); //撤销下、刷新商品列表
- if(pageType === "skip") {
- url = '/depotHead/addDepotHeadAndDetail'; //如果是从订单跳转过来,则此处为新增的接口
- //jshjshjsh
- $("#depotHeadFM .datagrid-body").find("[field='DepotId']").click();
- } else {
- url = '/depotHead/updateDepotHeadAndDetail?id=' + rowsdata.id; //更新接口
- }
-}
-
-//查看信息
-function showDepotHead(index){
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var manyAccountMoney = 0; //多账户合计-零售
- $("#ProjectIdShow").text(rowsdata.projectName);
- $("#NumberShow").text(rowsdata.number);
- $("#OperTimeShow").text(rowsdata.opertimeStr);
- $('#OrganIdShow').text(rowsdata.organName==undefined?'':rowsdata.organName);
- $("#HandsPersonIdShow").text(rowsdata.handsPersonName);
- if(rowsdata.accountName && rowsdata.accountName!=undefined){
- $("#AccountIdShow").text(rowsdata.accountName); //结算账户
- } else {
- var accountArr = (rowsdata.accountidlist==undefined?"":rowsdata.accountidlist).split(","); //账户id列表
- var accountMoneyArr =(rowsdata.accountmoneylist==undefined?"":rowsdata.accountmoneylist).split(","); //账户金额列表
- var accountIdShow = "";
- for(var j =0;j 查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- depotHeadID = rowsdata.id;
- initTableData_material_show(TotalPrice); //商品列表-查看状态
-}
-
-//绑定操作事件
-function bindEvent(){
- showDepotHeadDetails(1,initPageSize); //初始化时自动查询
- //搜索处理
- $("#searchBtn").off("click").on("click",function(){
- showDepotHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh',
- {
- pageNumber:1,
- pageSize:initPageSize
- });
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- //$("#searchProjectId").val("");
- $("#searchState").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //检查单据编号是否存在
- function checkDepotHeadNumber() {
- var thisNumber = $.trim($("#Number").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(thisNumber.length > 0 &&( oldNumber.length ==0 || thisNumber != oldNumber))
- {
- $.ajax({
- type:"get",
- url: "/depotHead/checkIsNumberExist",
- dataType: "json",
- async : false,
- data: ({
- DepotHeadID : oldId,
- Number : thisNumber
- }),
- success: function (tipInfo)
- {
- flag = tipInfo;
- if(tipInfo)
- {
- $.messager.alert('提示','抱歉,该单据编号已经存在','warning');
- return;
- }
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','检查单据编号是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
- //保存信息
- /**
- * 2019-01-25
- * 我对这个方法的实现结果存在严重怀疑,决定重构
- * 有如下疑点:
- * 1、保存完主表,返回结果后,再发起请求去操作子表,如何保证事务的一致性(业务数据一致性)
- * 2、保存完主表后,再通过selectmax的方式去获取主表主键id完全就是看人品的不可靠的思路
- * 修改计划:
- * 2019-01-25修改零售出库相关操作
- * 修改方式,重写url,将主从表操作合并
- *
- *
- * **/
- $("#saveDepotHead").off("click").on("click",function(){
- if(!$('#depotHeadFM').form('validate')){
- return;
- }
- else {
- //如果初始编号被修改了,就要判断单据编号是否存在
- if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
- //调用查询单据编号是否重名的方法
- if(checkDepotHeadNumber()){
- return;
- }
- }
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择往来单位!','warning');
- return;
- }
- if (editIndex != undefined) {
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- //进行明细的校验
- if(depotHeadID ==0) {
- //新增模式下
- if (!CheckData("add")) {
- return;
- }
- }
- else {
- //编辑模式下
- if (!CheckData("edit")) {
- return;
- }
- }
- var OrganId = null, ProjectId = null,AllocationProjectId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val())-0;
- var TotalPrice = $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text();
- if($('#OrganId').length){
- OrganId = $('#OrganId').combobox('getValue');
- }
- var accountMoneyList = $("#AccountId").attr("data-accountmoneyarr"); //账户金额列表-多账户
- var accountMoneyArr;
- if(accountMoneyList) {
- accountMoneyList = accountMoneyList.replace("[","").replace("]","").toString();
- var reg=new RegExp("\"","g"); //创建正则RegExp对象
- accountMoneyList = accountMoneyList.replace(reg,""); //替换所有的双引号
- accountMoneyArr = accountMoneyList.split(","); //转为数组
- }
- //零售时候,可以从会员预付款中扣款
- var thisPayType = "现付";
- var SalesmanStr = "";
- var getAccountID = $.trim($("#AccountId").val());
- if($("#AccountId").val() === "many"){ //多账户
- getAccountID = null;
- }
- var infoStr=JSON.stringify({
- Type: listType,
- SubType: listSubType,
- ProjectId: ProjectId,
- AllocationProjectId: AllocationProjectId,
- DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
- Number: $.trim($("#Number").val()),
- LinkNumber: $.trim($("#LinkNumber").val()),
- OperTime: $("#OperTime").val(),
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Salesman: SalesmanStr, //销售人员
- AccountId: getAccountID,
- ChangeAmount: ChangeAmount, //付款/收款
- TotalPrice: TotalPrice, //合计
- PayType: thisPayType, //现付/预付款
- Remark: $.trim($("#Remark").val()),
- AccountIdList: $("#AccountId").attr("data-accountarr"), //账户列表-多账户
- AccountMoneyList: accountMoneyArr ? JSON.stringify(accountMoneyArr) : "", //账户金额列表-多账户
- Discount: $.trim($("#Discount").val()),
- DiscountMoney: $.trim($("#DiscountMoney").val()),
- DiscountLastMoney: $.trim($("#DiscountLastMoney").val()),
- OtherMoney: $.trim($("#OtherMoney").val()), //采购费用、销售费用
- OtherMoneyList: $("#OtherMoney").attr("data-itemarr"), //支出项目列表-涉及费用
- OtherMoneyItem: $("#OtherMoney").attr("data-itemmoneyarr"), //支出项目金额列表-涉及费用
- AccountDay: $("#AccountDay").val() //结算天数
- });
- /**
- * 零售出库,单独操作
- * */
- if(url.indexOf("/depotHead/addDepotHeadAndDetail")>=0){
- addDepotHeadAndDetail(url,infoStr);
- return;
- }else if(url.indexOf("/depotHead/updateDepotHeadAndDetail")>=0){
- updateDepotHeadAndDetail(url,infoStr,preTotalPrice);
- return;
- }
- }
- });
-
- //打印单据
- $("#printDepotHeadShow").off("click").on("click",function(){
- var tableString = $("#depotHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event){
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="State"||obj.id=="Number"))
- {
- $("#saveDepotHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber"||obj.id=="searchMaterial"))
- {
- $("#searchBtn").click();
- }
- });
-
- //优惠率输入框事件
- $("#Discount").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountNum = $(this).val();
- var discountMoney = (discountNum/100*totalPrice).toFixed(2);
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#DiscountMoney").val(discountMoney); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //优惠金额输入框事件
- $("#DiscountMoney").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountMoney = $(this).val();
- var discount = (discountMoney/totalPrice).toFixed(2)*100;
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#Discount").val(discount); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //付款、收款输入框事件
- $("#ChangeAmount").off("keyup").on("keyup",function(){
- var discountLastMoney = $("#DiscountLastMoney").val();
- var changeAmount = $(this).val();
- var debtMoney = (discountLastMoney - changeAmount).toFixed(2);
- $("#Debt").val(debtMoney); //本次欠款
- });
-
- //多账户结算窗口弹出事件
- function depotHeadAccountDlgFun(){
- $('#depotHeadAccountDlg').dialog('open').dialog('setTitle','
多账户结算');
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").remove(); //先移除输入栏目
- $("#accountMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#depotHeadAccountDlg .tabs-tmp .account-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#depotHeadAccountDlg .tabs-tmp tbody").html();
- var accountDlgHead = $("#depotHeadAccountDlg .account-head-tmp");
- accountDlgHead.after(contentTmp);
- }
-
- //获取账户信息
- function accountDlgFun() {
- var options = "";
- if(accountList !=null){
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- }
- $(".account-id-dlg").empty().append("").append(options);
- }
- }
- accountDlgFun(); //获取账户信息
- $("#depotHeadAccountDlg .tabs-tmp").hide(); //隐藏模板
-
- //账户金额输入框事件-多账户
- $("#depotHeadAccountDlg .account-dlg .account-money-dlg").off("keyup").on("keyup",function(){
- var totalAccoutNum = 0;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var eachAccountMoney = $(this).find(".account-money-dlg").val()-0;
- totalAccoutNum += eachAccountMoney;
- });
- $("#accountMoneyTotalDlg").text(totalAccoutNum);
- });
-
- //结算多账户列表的切换事件
- $("#depotHeadAccountDlg .account-dlg .account-id-dlg").off("change").on("change",function(){
- var selectAccount = $(this).children('option:selected').text();
- if(selectAccount === ""){
- var thisMoneyDom = $(this).closest(".account-content-tmp").find(".account-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text() - 0;
- $("#accountMoneyTotalDlg").text(accountMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //账户为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveDepotHeadAccountDlg").off("click").on("click", function(){
- //完成多账户的json数据存储
- var accountArr = []; //账户id数组
- var accountMoneyArr = []; //账户金额数组
- var errorIndex = -1;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var thisAccId = $(this).find(".account-id-dlg").val();
- var thisAccMoney = $(this).find(".account-money-dlg").val();
- if(!thisAccId && thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && !thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && thisAccMoney) {
- accountArr.push(thisAccId);
- accountMoneyArr.push(thisAccMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var discountLastMoneyNum =$("#DiscountLastMoney").val()-0; //优惠后金额
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text()-0; //本次付款或者收款
- if(accountMoneyTotal===0){
- $.messager.alert('错误提示',"请填写金额后保存",'warning');
- return;
- }
- if(accountArr.length && accountMoneyArr.length) {
- $("#AccountId").attr("data-accountArr",JSON.stringify(accountArr)).attr("data-accountMoneyArr",JSON.stringify(accountMoneyArr)); //json数据存储
- }
- $("#ChangeAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
- $("#Debt").val((discountLastMoneyNum-accountMoneyTotal).toFixed(2)); //本次欠款
- $("#depotHeadAccountDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#AccountId").attr("data-accountArr")){
- $("#depotHeadAccountDlg").dialog('close');
- }
- else {
- $("#depotHeadAccountDlg").dialog('close');
- $("#AccountId").val("").removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- }
- //多账户-取消按钮
- $("#cancelDepotHeadAccountDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //多账户-右上角的关闭按钮
- $("#depotHeadAccountDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
- }
- //点击多账户,弹出输入框
- $("#AccountId").off("change").on("change",function(){
- var selectText = $(this).children('option:selected').text();
- if(selectText === "多账户"){
- $("#ChangeAmount").prop("readonly","readonly");
- depotHeadAccountDlgFun();
- $(".many-account-ico").show(); //显示多账户小图标
- }
- else{
- $(this).removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- });
-
- //结算账户-多账户小图标-点击事件
- $(".many-account-ico").off("click").on("click",function(){
- depotHeadAccountDlgFun();
- //给弹窗赋值-多账户数据
- var accountArr = $("#AccountId").attr("data-accountArr");
- accountArr = JSON.parse(accountArr);
- var accountMoneyArr = $("#AccountId").attr("data-accountMoneyArr");
- accountMoneyArr = JSON.parse(accountMoneyArr);
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".account-id-dlg").val(accountArr[index]);
- $(this).find(".account-money-dlg").val(accountMoneyArr[index]);
- });
- $("#accountMoneyTotalDlg").text($("#ChangeAmount").val());
- });
-
- //点击采购费用、销售费用的事件
- $(".other-money-ico").off("click").on("click",function(){
- $('#otherMoneyDlg').dialog('open').dialog('setTitle','
'+ listSubType +'费用');
- $("#otherMoneyDlg .money-dlg .money-content-tmp").remove(); //先移除输入栏目
- $("#otherMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#otherMoneyDlg .tabs-tmp .money-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#otherMoneyDlg .tabs-tmp tbody").html();
- var moneyDlgHead = $("#otherMoneyDlg .money-head-tmp");
- moneyDlgHead.after(contentTmp);
- }
-
- //获取支出项目信息
- function moneyDlgFun() {
- var options = "";
- if(outItemList !=null){
- for(var i = 0 ;i < outItemList.length;i++) {
- var money = outItemList[i];
- options += '';
- }
- $(".money-id-dlg").empty().append("").append(options);
- }
- }
- moneyDlgFun(); //获取支出项目信息
- $("#otherMoneyDlg .tabs-tmp").hide(); //隐藏模板
-
- //支出项目的金额输入框事件
- $("#otherMoneyDlg .money-dlg .other-money-dlg").off("keyup").on("keyup",function(){
- var totalMoneyNum = 0;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var eachOtherMoney = $(this).find(".other-money-dlg").val()-0;
- totalMoneyNum += eachOtherMoney;
- });
- $("#otherMoneyTotalDlg").text(totalMoneyNum);
- });
-
- //支出项目列表的切换事件
- $("#otherMoneyDlg .money-dlg .money-id-dlg").off("change").on("change",function(){
- var selectItem = $(this).children('option:selected').text();
- if(selectItem === ""){
- var thisMoneyDom = $(this).closest(".money-content-tmp").find(".other-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text() - 0;
- $("#otherMoneyTotalDlg").text(otherMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //支出项目为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveOtherMoneyDlg").off("click").on("click", function(){
- //完成支出项目的json数据存储
- var itemArr = []; //支出项目id数组
- var itemMoneyArr = []; //支出项目金额数组
- var errorIndex = -1;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var thisId = $(this).find(".money-id-dlg").val();
- var thisMoney = $(this).find(".other-money-dlg").val();
- if(!thisId && thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && !thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && thisMoney) {
- itemArr.push(thisId);
- itemMoneyArr.push(thisMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text()-0; //合计金额
- if(otherMoneyTotal === 0){ //0的时候清空缓存数据
- $("#OtherMoney").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr");
- }
- if(itemArr.length && itemMoneyArr.length) {
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
- $("#OtherMoney").val(otherMoneyTotal); //给采购费用、销售费用赋值
- $("#otherMoneyDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#OtherMoney").attr("data-itemArr")){
- $("#otherMoneyDlg").dialog('close');
- }
- else {
- $("#otherMoneyDlg").dialog('close');
- $("#OtherMoney").val("").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr"); //将下拉置空并把缓存参数清空
- }
- }
- //费用-取消按钮
- $("#cancelOtherMoneyDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //费用-右上角的关闭按钮
- $("#otherMoneyDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
-
- //给弹窗赋值-采购费用、销售费用数据
- var itemArr = $("#OtherMoney").attr("data-itemArr");
- itemArr = JSON.parse(itemArr);
- var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr");
- itemMoneyArr = JSON.parse(itemMoneyArr);
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".money-id-dlg").val(itemArr[index]);
- if(itemMoneyArr[index]!="undefined"){
- $(this).find(".other-money-dlg").val(itemMoneyArr[index]);
- }
- });
- $("#otherMoneyTotalDlg").text($("#OtherMoney").val());
- });
-}
-
-function showDepotHeadDetails(pageNo,pageSize){
- var materialParam = $.trim($("#searchMaterial").val());
- var beginTime = $.trim($("#searchBeginTime").val());
- var endTime = $.trim($("#searchEndTime").val());
- if(beginTime) {
- beginTime = beginTime + ' 00:00:00';
- }
- if(endTime) {
- endTime = endTime + ' 23:59:59';
- }
- $.ajax({
- type: "get",
- url: "/depotHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- subType: listSubType,
- state: $.trim($("#searchState").val()),
- number: $.trim($("#searchNumber").val()),
- beginTime: beginTime,
- endTime: endTime,
- materialParam: materialParam,
- depotIds: depotString
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#depotHeadFM .datagrid-body");
- var footer =$("#depotHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
- //点击商品下拉框,自动加载数量、单价、金额
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //点击库存文本框,字段计算库存
- body.find("[field='Stock']").find(input).off("click").on("click",function(){
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- var monthTime = getNowFormatMonth();
- if(depotId && mId){
- var ratio = body.find("[field='Unit']").find(input).attr("data-ratio");
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //在新增的时候,这个ratio有值;在编辑的时候,这个ratio为undefined
- var type = "click"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratio, type);
- }
- else{
- body.find("[field='Stock']").find(input).val(0).attr("data-stock",0); //加载库存数据
- }
- });
- //修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计
- body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber =$(this).val()-0; //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
-
- });
- //修改单价,自动计算金额和合计
- body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice =$(this).val()-0; //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击单价,自动提示参考价格列表
- body.find("[field='UnitPrice']").find(input).off("click").on("click",function(){
- var self = this;
- var mValue = body.find("[field='MaterialId'] .combo-value").attr("value"); //获取选中的商品id
- if(!mValue) {
- return;
- }
- else {
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mValue - 0
- },
- success: function(res){
- if(res && res.rows && res.rows[0]) {
- var retailPrice = res.rows[0].RetailPrice;
- var presetPriceOne = res.rows[0].PresetPriceOne;
- var presetPriceTwo = res.rows[0].PresetPriceTwo;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- 批发价:" + presetPriceTwo + "
";
- temp +="- 零售价:" + retailPrice + "
";
- temp +="
";
- temp +="
";
- if($('.price-list').length){
- $('.price-list').remove(); //如果存在价格列表先移除
- }
- else {
- if(presetPriceTwo != undefined){ //多单位的商品
- $(self).after(temp); //加载列表信息
- }
- }
- $('.price-list ul li').off("click").on("click",function(){
- var price = $(this).text();
- price = price.substring(price.indexOf(":") + 1);
- $(self).val(price);
- $(self).keyup(); //模拟键盘操作
- $('.price-list').remove(); //移除价格列表
- });
- //点击空白处移除价格列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.price-list').remove(); //移除价格列表
- });
- }
- },
- error: function(){
- $.messager.alert('错误提示','查询商品信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- //修改含税单价,自动计算单价、金额、税额、价税合计和合计
- body.find("[field='TaxUnitPrice']").find(input).off("keyup").on("keyup",function(){
- var TaxUnitPrice =$(this).val()-0; //含税单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var UnitPrice = TaxUnitPrice/(1+taxRate/100); //计算单价
- body.find("[field='UnitPrice']").find(input).val((UnitPrice).toFixed(2)); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改金额,自动计算单价、税额、价税合计和合计
- body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var AllPrice =$(this).val()-0; //金额
- var UnitPrice = (AllPrice/OperNumber).toFixed(2);
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税率,自动计算含税单价、税额、价税合计和合计
- body.find("[field='TaxRate']").find(input).off("keyup").on("keyup",function(){
- var taxRate =$(this).val()-0; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税额,自动计算税率、含税单价、价税合计和合计
- body.find("[field='TaxMoney']").find(input).off("keyup").on("keyup",function(){
- var taxMoney =$(this).val()-0; //税额
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = taxMoney/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改价税合计,自动计算税率、含税单价、税额和合计
- body.find("[field='TaxLastMoney']").find(input).off("keyup").on("keyup",function(){
- var taxLastMoney =$(this).val()-0; //价税合计
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = (taxLastMoney-AllPrice)/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
-
- //加载税率
- if(thisTaxRate) {
- body.find("[field='TaxRate']").find(input).val(thisTaxRate);
- }
- else {
- body.find("[field='TaxRate']").find(input).val(0); //默认为0
- }
-
- //在商品类型加载 组装件、普通子件
- var mType = body.find("[field='MType']");
- var rowListLength = mType.find(input).closest(".datagrid-row").attr("datagrid-row-index");
- var mTypeValue = "组合件";
- if(rowListLength > 0){
- mTypeValue = "普通子件";
- }
- },500);
-}
-
-//结束编辑
-function endEditing() {
- if (editIndex == undefined) { return true }
- if ($('#materialData').datagrid('validateRow', editIndex)) {
- //仓库信息
- var edDepot = $('#materialData').datagrid('getEditor', {index:editIndex,field:'DepotId'});
- var DepotName = $(edDepot.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName;
- //商品信息
- var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'});
- var MaterialName = $(edMaterial.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName;
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#materialData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append(){
- if (endEditing()) {
- $('#materialData').datagrid('appendRow', {DepotId:defDepotId});
- editIndex = $('#materialData').datagrid('getRows').length - 1;
- $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function batchDel(){
- /**
- * 重写一下删除的逻辑
- * 获取所有选中行,直接从列表中移除
- * 点击保存时,将需要后台删除的数据提交到服务器
- * **/
- /**
- * create by: qiankunpingtai
- * create time: 2019/3/20 16:26
- * description:
- * 这个地方比较坑的,花了一个多小时才搞明白为什么
- * 1、删除之前必须先调用endEditing结束编辑
- * 2、如果只是调用endEditing结束编辑那么正在编辑行的被选中状态会被去掉
- * 所以要在调用endEditing先获取选中的行
- */
- //如果编辑的行一开始是选中状态,结束编辑后仍然是选中状态
- var row = $('#materialData').datagrid('getChecked');
- if (endEditing()) {
- if (row.length == 0) {
- $.messager.alert('删除提示', '没有记录被选中!', 'info');
- return;
- }
- if (row.length > 0) {
- $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条单据信息吗?', function (r) {
- if (r) {
- for (var i = 0; i < row.length; i++) {
- $('#materialData').datagrid('deleteRow', $('#materialData').datagrid("getRowIndex", row[i]));
- }
- }
- });
- }
- }
-}
-function removeit(){
- if (editIndex == undefined) { return }
- $('#materialData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#materialData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData(type) {
- var change = $('#materialData').datagrid('getChanges').length;
- if(type =="add" && !change) {
- $.messager.alert('提示','请输入明细信息!','warning');
- return false;
- }
- var row = $('#materialData').datagrid('getRows');
- if(!row.length){
- $.messager.alert('提示',"请输入明细信息!",'info');
- return false;
- }
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if (row[i].DepotId == "" || row[i].MaterialId == "" || row[i].OperNumber == "" || row[i].UnitPrice === "" || row[i].AllPrice === "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-
-
-/**
- * 新增单据主表及单据子表
- * */
-function addDepotHeadAndDetail(url,infoStr){
- var inserted = null;
- if(pageType === "skip") {
- inserted = $("#materialData").datagrid('getChanges', "updated");
- } else {
- inserted = $("#materialData").datagrid('getChanges', "inserted");
- }
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated)
- }),
- success: function (tipInfo){
-
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
-
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
-
-
- });
-}
-/**
- * 修改单据主表及单据子表
- * */
-function updateDepotHeadAndDetail(url,infoStr,preTotalPrice){
- var inserted = $("#materialData").datagrid('getChanges', "inserted");
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- id:url.substring(url.lastIndexOf("?id=")+4,url.length),
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- preTotalPrice:preTotalPrice
- }),
- success: function (tipInfo){
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
- if (endEditing()) {
- $('#materialData').datagrid('acceptChanges');
- }
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-
-
-
diff --git a/erp_web/js/pages/materials/purchase_back_list.js b/erp_web/js/pages/materials/purchase_back_list.js
deleted file mode 100644
index f47970ec..00000000
--- a/erp_web/js/pages/materials/purchase_back_list.js
+++ /dev/null
@@ -1,2411 +0,0 @@
-//初始化界面
-var defDepotId = null;
-var kid = sessionStorage.getItem("userId");
-var pageType = getUrlParam('t'); //获取页面类型传值
-var depotList = null;
-var depotID = null;
-var supplierList = null;
-var supplierID = null;
-var personList = null;
-var personID = null;
-var ProjectSearch=null;
-var userBusinessList=null;
-var userdepot=null;
-var url;
-var depotHeadID = 0;
-var preTotalPrice = 0; //前一次加载的金额
-var orgDepotHead = "";
-var editIndex = undefined;
-/**默认编号有意义吗,不如空着吧*/
-var orgDefaultId=''; //单位默认编号
-var orgDefaultList; //存储查询出来的会员列表
-var accountList; //账户列表
-var outItemList; //支出项目列表
-var thisTaxRate = 0; //当前税率,选择供应商或者客户的时候设置
-var oldNumber = ""; //编辑前的单据编号
-var oldId = 0; //编辑前的单据Id
-var otherColumns = true; //明细中的‘别名’列是否显示
-var btnEnableList = getBtnStr(); //获取按钮的权限
-var mPropertyList = ""; //商品属性列表
-var defaultAccountId = 0; //默认账户id
-//改变宽度和高度
-$("#searchPanel").panel({width:webW-2});
-$("#tablePanel").panel({width:webW-2});
-var listTitle = "采购退货列表"; //单据标题
-var depotString = "|"; //店铺id列表
-var listType ="出库";//入库 出库
-var listSubType = "采购退货"; //采购 销售等
-var payTypeTitle = "收款"; //付款 收款
-var organUrl = "/supplier/findBySelect_sup"; //组织数据接口地址
-var amountNum ="CGTH";//单据编号开头字符
-$(function(){
- //初始化系统基础信息
- initSystemData_UB();
- initSelectInfo_UB();
- initSystemData_depot();
- initSelectInfo_depot();
- initSystemData_person();
- initSelectInfo_person();
- initSystemData_account();
- initSelectInfo_account();
- initSupplier(); //供应商
- initSalesman(); //销售人员
- initOutItemList(); //初始化支出项目
- initMProperty(); //初始化商品属性
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
-});
-//初始化系统基础信息
-function initSystemData_UB(){
- $.ajax({
- type:"get",
- url: "/userBusiness/getBasicData",
- data: ({
- KeyId:kid,
- Type:"UserDepot"
- }),
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if (res && res.code === 200) {
- userBusinessList = res.data.userBusinessList;
- }
- else {
- userBusinessList = null;
- }
- }
- });
-
-}
-//初始化页面选项卡
-function initSelectInfo_UB(){
-
- if(userBusinessList !=null)
- {
- if(userBusinessList.length>0)
- {
- //用户对应的仓库列表 [1][2][3]...
- userdepot =userBusinessList[0].value;
- }
- }
-}
-
-
-//初始化系统基础信息
-function initSystemData_depot(){
- $.ajax({
- type:"get",
- url: "/depot/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200){
- depotList = res.data;
- } else {
- $.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error');
- return;
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_depot(){
- var options = "";
-
- if(depotList !=null)
- {
- options = "";
- for(var i = 0 ;i < depotList.length;i++)
- {
- var depot = depotList[i];
-
- if(userdepot!=null)
- {
- if(userdepot.indexOf("["+depot.id+"]")!=-1)
- {
- if(depot.isDefault){
- defDepotId = depot.id;
- }
- options += '';
- depotString = depotString + depot.id + ",";
- }
- }
- if(depot.type === 1){
- depotString = depotString + depot.id + ",";
- }
- }
- depotString = depotString.substring(1, depotString.length-1);
- $("#ProjectId").empty().append(options);
- $("#AllocationProjectId").empty().append(options);
- $("#searchProjectId").empty().append('').append(options);
- }
-}
-
-//初始化供应商、客户、散户信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onLoadSuccess: function(res) {
- var data = $(this).combobox('getData');
- for(var i = 0; i<= data.length; i++){
- if(data && data[i] && data[i].supplier === "非会员"){
- orgDefaultId = data[i].id;
- }
- }
- },
- onSelect: function(rec){
- $.ajax({
- type:"get",
- url: "/supplier/findById",
- data: {
- supplierId: rec.id
- },
- dataType: "json",
- success: function (res){
- if(res && res.code === 200) {
- if(res.data && res.data[0]){
- thisTaxRate = res.data[0].taxRate; //设置当前的税率
- }
- }
- },
- error:function(){
-
- }
- });
- }
- });
-}
-
-//初始化销售人员
-function initSalesman(){
- $('#Salesman').combobox({
- url: "/person/getPersonByNumType?type=1",
- valueField:'id',
- textField:'name',
- multiple: true
- });
-}
-
-//初始化收入项目列表
-function initOutItemList(){
- $.ajax({
- type:"get",
- url: "/inOutItem/findBySelect?type=out",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res){
- if(res){
- outItemList = res;
- }
- },
- error:function(){
-
- }
- });
-}
-
-//初始化商品属性
-function initMProperty(){
- $.ajax({
- type: "get",
- url: "/materialProperty/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- name: ""
- }),
- currentPage: 1,
- pageSize: 100
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- var thisRows = res.data.page.rows;
- for (var i = 0; i < thisRows.length; i++) {
- if (thisRows[i].enabled) {
- mPropertyList += thisRows[i].nativename + ",";
- }
- }
- if (mPropertyList) {
- mPropertyList = mPropertyList.substring(0, mPropertyList.length - 1);
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化系统基础信息
-function initSystemData_person(){
- $.ajax({
- type:"get",
- url: "/person/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- personList = res.data.personList;
- }
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_person(){
- var options1 = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="仓管员")
- {
- options1 += '';
- }
- }
- $("#HandsPersonId").empty().append(options1);
- }
-}
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null){
- options = "";
- options += "";
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- if(account.isdefault) {
- defaultAccountId = account.id; //给账户赋值默认id
- }
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#depotHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- if(pageType === "skip") {
- var oldRowInfo = sessionStorage.getItem("rowInfo");
- editDepotHead(oldRowInfo); //自动弹出编辑框,带缓存数据
- }
- var hideType = undefined;
- var isHiddenStatus = true;
- var tableToolBar = [
- {
- id:'addDepotHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addDepotHead();
- }
- },
- {
- id:'deleteDepotHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteDepotHead();
- }
- }
- ];
- //如果允许的按钮列表中存在就显示,3-代表审核|反审核的权限
- if(btnEnableList && btnEnableList.indexOf(3)>-1){
- isHiddenStatus = false; //显示
- tableToolBar.push({
- id:'okDepotHead',
- text:'审核',
- iconCls:'icon-ok',
- handler:function() {
- setStatusFun();
- }
- },
- {
- id:'undoDepotHead',
- text:'反审核',
- iconCls:'icon-undo',
- handler:function() {
- setUnStatusFun();
- }
- });
- }
- else {
- isHiddenStatus = true; //隐藏
- }
- var isShowLastMoneyColumn = false; //是否显示优惠后金额和价税合计,true为隐藏,false为显示
- var isShowOrganNameColumn = false; //是否显示供应商、客户等信息,true为隐藏,false为显示
- var organNameTitle = "供应商名称"; //组织名称标题
- var opWidth = 90; //操作宽度
- var opTitle = ""; //跳转按钮的标题
- $('#tableData').datagrid({
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: true,
- //交替出现背景
- striped : true,
- pageSize: 10,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:opWidth,
- formatter:function(value, rec,index) {
- var str = '';
- var orgId = rec.organid? rec.organid:0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
- { title: '单据编号',field: 'number',width:135, formatter:function (value,rec) {
- if(rec.linknumber) {
- return value + "[转]";
- } else {
- return value;
- }
- }
- },
- { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
- if(value) {
- return value.replace(",",",");
- }
- }
- },
- { title: '单据日期',field: 'opertimeStr',width:130},
- { title: '操作员',field: 'operpersonname',width:60},
- { title: '金额合计',field: 'totalprice',width:60},
- { title: '含税合计',field: 'totaltaxlastmoney',hidden:isShowLastMoneyColumn,width:60,formatter:function(value,rec){
- return (rec.discountmoney + rec.discountlastmoney).toFixed(2);
- }
- },
- { title: '优惠后金额',field: 'discountlastmoney',hidden:isShowLastMoneyColumn,width:80},
- { title: payTypeTitle,field: 'changeamount',width:50,hidden:hideType},
- { title: '状态',field: 'status',hidden:isHiddenStatus, width:70,align:"center",formatter:function(value){
- if(value === "0") {
- return "未审核";
- } else if(value === "1") {
- return "已审核";
- } else if(value === "2") {
- }
- }
- }
- ]],
- toolbar:tableToolBar,
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//查找库存的方法
-function findStockNumById(depotId, mId, monthTime, body, input, ratio, type){
- var thisRatio = 1; //比例
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (rec) {
- if(rec && rec.code === 200 && rec.data && rec.data[0]) {
- var loadRatio = 1; //在单位输入框上面加载比例字段
- if(rec.data[0].unit) { //如果存在计量单位信息
- loadRatio = 1;
- }
- else{
- var unitName = rec.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- thisRatio = unitName.substring(unitName.indexOf(":")+1).replace(")","");
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- unitSetInput = rec.data[0].firstinunit;
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = thisRatio;
- }
- }
- //查询库存
- $.ajax({
- type: "get",
- url: '/depotItem/findStockNumById',
- data:{
- projectId: depotId,
- materialId: mId
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if (res.data && res.data.page && res.data.page[0]) {
- var thisStock = res.data.page[0].thisSum;
- if (type == "select") { //选择下拉框的时候
- if (ratio != undefined && ratio != 1) {
- loadRatio = ratio;
- }
- }
- else if (type == "click") { //点击库存的时候
- if (ratio != undefined) {
- loadRatio = ratio;
- }
- }
- thisStock = (thisStock / loadRatio).toFixed(2);
- body.find("[field='Stock']").find(input).val(thisStock).attr("data-stock", res.data.page[0].thisSum); //加载库存数据
- }
- else {
- body.find("[field='Stock']").find(input).val(0).attr("data-stock", 0); //加载库存数据
- }
- body.find("[field='Stock']").find(input).prop("readonly", "readonly"); //设置库存数据为只读
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
- }
- },
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- }
- });
-}
-//优惠率、合计的统计方法
-function statisticsFun(body,UnitPrice,OperNumber,footer,taxRate){
- var TotalPrice = 0;
- var taxLastMoneyTotal = 0;
- //金额的合计
- body.find("[field='AllPrice']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + UnitPrice*OperNumber;
- footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); //金额的合计
- //价税合计的总计
- body.find("[field='TaxLastMoney']").each(function(){
- if($(this).find("div").text()!==""){
- taxLastMoneyTotal = taxLastMoneyTotal + (parseFloat($(this).find("div").text().toString())-0);
- }
- });
- taxLastMoneyTotal = taxLastMoneyTotal + (UnitPrice*OperNumber*(1+taxRate/100));
- footer.find("[field='TaxLastMoney']").find("div").text((taxLastMoneyTotal).toFixed(2)); //价税合计的页脚总计
- var discount = $("#Discount").val(); //优惠率
- var discountMoney = (taxLastMoneyTotal*discount/100).toFixed(2);
- $("#DiscountMoney").val(discountMoney);//优惠金额
- var discountLastMoney = (taxLastMoneyTotal*(1-discount/100)).toFixed(2)
- $("#DiscountLastMoney").val(discountLastMoney);//优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
-
-}
-//初始化表格数据-商品列表-编辑状态
-function initTableData_material(type,TotalPrice){
- var body,footer,input; //定义表格和文本框
- var ratio = 1; //比例-品名专用
- var ratioDepot = 1; //比例-仓库用
- var monthTime = getNowFormatMonth();
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var depotHeadName = ""; //仓库名称
- var depotUrl = ""; //仓库接口地址
- var depotTextField = ""; //仓库下拉名称
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var anotherDepotUrl = ""; //对方仓库接口地址
- var anotherDepotTextField = "";
- depotHeadName = "仓库名称";
- depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- depotTextField = "depotName";
- var isShowTaxColumn = false; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialData').datagrid({
- height:245,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: '商品类型',field: 'MType',editor:'validatebox',hidden:isShowMaterialTypeColumn,width:80},
- { title: depotHeadName, field: 'DepotId', editor: 'validatebox', width: 90,
- formatter: function (value, row, index) {
- return row.DepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: depotTextField,
- method: 'get',
- url: depotUrl,
- onSelect:function(rec){
- var depotId = rec.id;
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- if(mId){
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratioDepot, type);
- }
- }
- }
- }
- },
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialId',width:230,
- formatter:function(value,row,index){
- return row.MaterialName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'MaterialName',
- method:'get',
- url: "/material/findBySelect",
- panelWidth: 300, //下拉框的宽度
- //全面模糊匹配,过滤字段
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onBeforeLoad: function(param){
- param.mpList = mPropertyList; //商品属性
- },
- onSelect:function(rec){
- if(rec) {
- var mId = rec.Id;
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (res) {
- if(res && res.code === 200 && res.data && res.data[0]) {
- var retailPrice = res.data[0].retailprice-0; //零售价格
- var presetPriceOne = res.data[0].presetpriceone-0; //预计采购价
- var presetPriceTwo = res.data[0].presetpricetwo-0; //批发价
- var firstInUnit = res.data[0].firstinunit; //首选入库单位
- var firstOutUnit = res.data[0].firstoutunit; //首选出库单位
- var basicPresetPriceOne = ""; //多单位-入库-基础价格
- var basicPresetPriceTwo = ""; //多单位-出库-基础价格
- var retailPriceOne = ""; //多单位-入库-零售价格
- var otherPresetPriceOne = ""; //多单位-入库-其他价格
- var otherPresetPriceTwo = ""; //多单位-出库-其他价格
- var retailPriceTwo = ""; //多单位-出库-零售价格
- var basicUnit = ""; //基础单位
- var otherUnit = ""; //其他单位
- if(!res.data[0].unit){
- var ps = res.data[0].pricestrategy;
- var psObj = JSON.parse(ps);
- basicPresetPriceOne = psObj[0].basic.PresetPriceOne-0;
- basicPresetPriceTwo = psObj[0].basic.PresetPriceTwo-0;
- retailPriceOne = psObj[0].basic.RetailPrice-0;
- otherPresetPriceOne = psObj[1].other.PresetPriceOne-0;
- otherPresetPriceTwo = psObj[1].other.PresetPriceTwo-0;
- retailPriceTwo = psObj[1].other.RetailPrice-0;
- basicUnit = psObj[0].basic.Unit;
- otherUnit = psObj[1].other.Unit;
- }
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- if(res.data[0].unit){ //如果存在计量单位信息
- ratio = 1; //重置比例为1
- body.find("[field='Unit']").find(input).val(res.data[0].unit); //设置-计量单位信息
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- body.find("[field='Unit']").find(input).off("click"); //移除点击事件
- body.find("[field='Unit']").find(input).attr("data-ratio",ratio); //修改比例缓存信息
- }
- else {
- var unitName = res.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- var loadRatio = 1; //在单位输入框上面加载比例字段
- unitSetInput = res.data[0].firstinunit; //给单位文本框赋值
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = ratio;
- }
- body.find("[field='Unit']").find(input).val(unitSetInput).attr("data-ratio", loadRatio); //设置-首选单位
-
- body.find("[field='Unit']").find(input).off("click").on("click",function(){
- if(basicUnit && otherUnit) {
- var self = this;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- " + basicUnit + "
";
- temp +="- " + otherUnit + "
";
- temp +="
";
- temp +="
";
- if($('.unit-list').length){
- $('.unit-list').remove(); //如果存在计量单位列表先移除
- }
- else {
- $(self).after(temp); //加载列表信息
- }
- //计量单位列表的单击事件
- $('.unit-list ul li').off("click").on("click",function(){
- var unit = $(this).text();
- var thisRatio = $(this).attr("data-ratio"); //获取比例
- $(self).val(unit).attr("data-ratio", thisRatio);
- $(self).keyup(); //模拟键盘操作
- $('.unit-list').remove(); //移除计量单位列表
- var stock = body.find("[field='Stock']").find(input).attr("data-stock"); //从缓存中取值
- var type = $(this).attr("data-type");
- var UnitPrice = 0;
- if(type === "basic"){
- UnitPrice = basicPresetPriceTwo;
- body.find("[field='Stock']").find(input).val(stock); //修改库存
- }
- else if(type === "other"){
- UnitPrice = otherPresetPriceTwo;
- body.find("[field='Stock']").find(input).val((stock/ratio).toFixed(2)); //修改库存
- }
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //获取数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击空白处移除计量单位列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.unit-list').remove(); //移除计量单位列表
- });
- }
- });
- }
- var detailPrice = 0; //明细列表-单价
- if(res.data[0].unit) { //如果存在计量单位信息
- detailPrice = presetPriceOne;
- }
- else {
- if (firstInUnit == basicUnit) {
- detailPrice = basicPresetPriceOne;
- }
- else if (firstInUnit == otherUnit) {
- detailPrice = otherPresetPriceOne;
- }
- }
- body.find("[field='OperNumber']").find(input).val(1); //数量初始化为1
- //单价和总价赋值
- if(!detailPrice) {
- detailPrice = 0;
- }
- body.find("[field='UnitPrice']").find(input).val(detailPrice);
- body.find("[field='AllPrice']").find(input).val(detailPrice);
- var taxRate = body.find("[field='TaxRate']").find(input).val()-0; //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((detailPrice*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,detailPrice,1,footer,taxRate);
-
- //查询库存信息
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- if(depotId) {
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, loadRatio, type);
- }
- }
- },
- error: function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- }
- });
- }
- }
- }
- }
- },
- { title: '库存',field: 'Stock',editor:'validatebox',width:70},
- { title: anotherDepotHeadName, field: 'AnotherDepotId',editor:'validatebox',hidden:isShowAnotherDepot,width:90,
- formatter: function (value, row, index) {
- return row.AnotherDepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: anotherDepotTextField,
- method: 'get',
- url: anotherDepotUrl
- }
- }
- },
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率(%)',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batchDel(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = 0;
- var TaxLastMoney = 0;
- var DiscountMoney = $("#DiscountMoney").val()-0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoney").val()-0; //优惠后金额
- if(type === "edit") {
- AllPrice = TotalPrice;
- TaxLastMoney = DiscountMoney + DiscountLastMoney;
- }
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": TaxLastMoney
- });
- data.footer = array;
- $("#materialData").datagrid('loadData',data);
- //如果是订单跳转到采购或销售
- if(pageType === "skip") {
- var skipList = $("#depotHeadFM .datagrid-body tr");
- //逐条自动点击每行数据
- skipList.each(function (i) {
- setTimeout(function () {
- skipList.eq(i).find("[field='Stock']").click();
- },(i+1)*1000);
- });
- }
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//初始化表格数据-商品列表-查看状态
-function initTableData_material_show(TotalPrice){
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var depotHeadName = ""; //仓库的列的标题
- depotHeadName = "仓库名称";
- var isShowTaxColumn = false; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialDataShow').datagrid({
- height:245,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- onClickRow: onClickRow,
- columns:[[
- { title: '商品类型',field: 'MType',width:80, hidden:isShowMaterialTypeColumn},
- { title: depotHeadName,field: 'DepotName',editor:'validatebox',width:90},
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialName',width:230},
- { title: anotherDepotHeadName,field: 'AnotherDepotName',hidden:isShowAnotherDepot,width:90},
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validattebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = TotalPrice;
- var DiscountMoney = $("#DiscountMoneyShow").text() - 0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoneyShow").text() - 0; //优惠后金额
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": DiscountMoney + DiscountLastMoney
- });
- data.footer = array;
- $("#materialDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showDepotHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除单据信息
-function deleteDepotHead(depotHeadID, thisOrganId, totalPrice, status){
- if(status == "1" || status == "2") {
- $.messager.alert('删除提示','已审核和已转的单据不能删除!','warning');
- return;
- }
- $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
- if (r) {
- $.ajax({
- type:"post",
- // url: "/depotHead/" + depotHeadID + "/delete",
- url: "/depotHead/deleteDepotHeadAndDetail",
- dataType: "json",
- data:{
- id: depotHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-//订单转采购或销售
-function skipDepotHead(index, status){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- if(status == "0" || status == "2") {
- $.messager.alert('提示','未审核和已转的单据禁止操作!','warning');
- } else {
- sessionStorage.setItem("rowInfo", JSON.stringify(rowsdata)); //将单据信息存入缓存中
- }
-}
-
-//批量删除单据信息
-function batDeleteDepotHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条单据信息吗?',function(r)
- {
- if (r) {
- var ids = "";
- for (var i = 0; i < row.length; i++) {
- if (i == row.length - 1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- if (ids) {
- //批量删除
- $.ajax({
- type: "post",
- // url: "/depotHead/batchDelete",
- url: "/depotHead/batchDeleteDepotHeadAndDetail",
- dataType: "json",
- async: false,
- data: ({
- ids: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除单据信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('删除提示','没有能删除的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量审核
-function setStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('审核确认','确定要审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: "1",
- depotHeadIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('审核提示', '审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('审核提示','审核信息异常,请稍后再试!','error');
- return;
- }
- });
- } else {
- $.messager.alert('审核提示','没有能审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量反审核
-function setUnStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('反审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('反审核确认','确定要反审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type: "post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async: false,
- data: ({
- status: "0",
- depotHeadIDs: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('反审核提示', '反审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('反审核提示', '反审核信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('反审核提示','没有能反审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//生成单据编号
-function buildNumber() {
- $.ajax({
- type: "get",
- url: "/depotHead/buildNumber",
- success:function(res){
- if(res && res.code === 200){
- var obj = res.data;
- var defaultNumber = obj.DefaultNumber;
- var newNumber = amountNum + defaultNumber;
- $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
- }
- },
- error:function(){
- $.messager.alert('提示','生成单据编号失败!','error');
- }
- });
-}
-
-//新增信息
-function addDepotHead(){
- $('#depotHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- buildNumber(); //生成单据编号
- //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为0
- $("#Discount").val(0);
- $("#DiscountMoney").val(0);
- $("#DiscountLastMoney").val(0);
- $("#ChangeAmount").val(0);
- $("#Debt").val(0);
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- var addTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgDepotHead = "";
- depotHeadID = 0;
- initTableData_material("add"); //商品列表
- reject(); //撤销下、刷新商品列表
- $("#addOrgan").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加供应商信息');
- $('#supplierFM').form('clear');
- });
-
- $("#addMember").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加会员信息');
- $('#supplierFM').form('clear');
- });
- $("#addCustomer").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加客户信息');
- $('#supplierFM').form('clear');
- });
- url = '/depotHead/addDepotHeadAndDetail';
-}
-
-//编辑信息
-function editDepotHead(index, status){
- if(status == "1" || status == "2") {
- $.messager.alert('编辑提示','已审核和已转的单据不能编辑!','warning');
- return;
- }
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata ='';
- if(Number(index).toString()=='NaN'){
- rowsdata=$.parseJSON(index);
- }else{
- rowsdata=$("#tableData").datagrid("getRows")[index];
- }
- $("#ProjectId").focus().val(rowsdata.projectid);
- var ProjectId=rowsdata.projectid;
- if(ProjectId!='') {
- initSystemData_person(ProjectId);
- initSelectInfo_person();
- }
- var TotalPrice = rowsdata.totalprice; //合计金额
- if(pageType === "skip") { //从订单跳转过来
- buildNumber(); //生成单据编号
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- $("#LinkNumber").val(rowsdata.number); //关联订单号
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- $("#DiscountLastMoney").val(TotalPrice); //优惠后金额
- $("#ChangeAmount").val(TotalPrice).attr("data-changeamount", TotalPrice);
- } else {
- $("#Number").val(rowsdata.number).attr("data-defaultNumber",rowsdata.number);
- $("#OperTime").val(rowsdata.opertimeStr);
- $("#LinkNumber").val(rowsdata.linknumber==undefined?"":rowsdata.linknumber); //关联订单号
- $("#AccountId").val(rowsdata.accountid); //账户Id
- $("#DiscountLastMoney").val(rowsdata.discountlastmoney==undefined?"0.00":rowsdata.discountlastmoney); //优惠后金额
- $("#ChangeAmount").val(rowsdata.changeamount).attr("data-changeamount", rowsdata.changeamount);
- }
- $('#OrganId').combobox('setValue', rowsdata.organid==undefined?'':rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#Remark").val(rowsdata.remark);
- $("#Discount").val(rowsdata.discount==undefined?"0":rowsdata.discount);
- $("#DiscountMoney").val(rowsdata.discountmoney==undefined?"0.00":rowsdata.discountmoney);
- $("#Debt").val(Number((rowsdata.discountlastmoney==undefined?'0.00':rowsdata.discountlastmoney-rowsdata.changeamount)).toFixed(2));
- $("#AccountDay").val(rowsdata.accountday==undefined?"":rowsdata.accountday); //结算天数
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于扣预付款
- $("#AllocationProjectId").val(rowsdata.allocationprojectid);
- oldNumber = rowsdata.number; //记录编辑前的单据编号
- oldId = rowsdata.id; //记录单据Id
- var editTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- depotHeadID = rowsdata.id;
-
- //采购入库、销售出库的多账户加载
- if(rowsdata.accountidlist!=undefined && rowsdata.accountmoneylist!=undefined){
- $("#AccountId").val("many"); //下拉框选中多账户
- var accountArr = rowsdata.accountidlist.split(",");
- var accountMoneyArr = rowsdata.accountmoneylist.split(",");
- accountMoneyArr = changeListFmtPlus(accountMoneyArr) //将数组单个金额中的数值转为正数
-
- if(listSubType == "零售" || listSubType == "零售退货") {
- var manyAccountMoney = 0; //多账户合计-零售
- for (var j = 0; j < accountArr.length; j++) {
- if (accountList != null) {
- for (var i = 0; i < accountList.length; i++) {
- var account = accountList[i];
- if (accountArr[j] == account.id) {
- manyAccountMoney += accountMoneyArr[j] - 0; //多账户合计-零售
- }
- }
- }
- }
- $("#getAmount").val(manyAccountMoney); //收款金额、付款金额
- var changeAmount = $("#ChangeAmount").val()-0;
- $("#backAmount").val((manyAccountMoney-changeAmount).toFixed(2)); //找零
- }
-
- $("#AccountId").attr("data-accountArr", JSON.stringify(accountArr)).attr("data-accountMoneyArr", JSON.stringify(accountMoneyArr)); //json数据存储
- $(".many-account-ico").show(); //显示多账户的ico图标
- }
-
- //采购入库、销售出库的费用数据加载
- if(rowsdata.othermoneylist &&rowsdata.othermoneyitem){
- $("#OtherMoney").val(rowsdata.othermoney==undefined?"0":rowsdata.othermoney); //采购费用、销售费用
- var itemArr = rowsdata.othermoneylist.split(",");
- var itemMoneyArr = rowsdata.othermoneyitem.split(",");
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
-
- initTableData_material("edit",TotalPrice); //商品列表
- reject(); //撤销下、刷新商品列表
- if(pageType === "skip") {
- url = '/depotHead/addDepotHeadAndDetail'; //如果是从订单跳转过来,则此处为新增的接口
- //jshjshjsh
- $("#depotHeadFM .datagrid-body").find("[field='DepotId']").click();
- } else {
- url = '/depotHead/updateDepotHeadAndDetail?id=' + rowsdata.id; //更新接口
- }
-}
-
-//查看信息
-function showDepotHead(index){
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var manyAccountMoney = 0; //多账户合计-零售
- $("#ProjectIdShow").text(rowsdata.projectName);
- $("#NumberShow").text(rowsdata.number);
- $("#OperTimeShow").text(rowsdata.opertimeStr);
- $('#OrganIdShow').text(rowsdata.organName==undefined?'':rowsdata.organName);
- $("#HandsPersonIdShow").text(rowsdata.handsPersonName);
- if(rowsdata.accountName && rowsdata.accountName!=undefined){
- $("#AccountIdShow").text(rowsdata.accountName); //结算账户
- } else {
- var accountArr = (rowsdata.accountidlist==undefined?"":rowsdata.accountidlist).split(","); //账户id列表
- var accountMoneyArr =(rowsdata.accountmoneylist==undefined?"":rowsdata.accountmoneylist).split(","); //账户金额列表
- var accountIdShow = "";
- for(var j =0;j 查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- depotHeadID = rowsdata.id;
- initTableData_material_show(TotalPrice); //商品列表-查看状态
-}
-
-//绑定操作事件
-function bindEvent(){
- showDepotHeadDetails(1,initPageSize); //初始化时自动查询
- //搜索处理
- $("#searchBtn").off("click").on("click",function(){
- showDepotHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh',
- {
- pageNumber:1,
- pageSize:initPageSize
- });
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- //$("#searchProjectId").val("");
- $("#searchState").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //检查单据编号是否存在
- function checkDepotHeadNumber() {
- var thisNumber = $.trim($("#Number").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(thisNumber.length > 0 &&( oldNumber.length ==0 || thisNumber != oldNumber))
- {
- $.ajax({
- type:"get",
- url: "/depotHead/checkIsNumberExist",
- dataType: "json",
- async : false,
- data: ({
- DepotHeadID : oldId,
- Number : thisNumber
- }),
- success: function (tipInfo)
- {
- flag = tipInfo;
- if(tipInfo)
- {
- $.messager.alert('提示','抱歉,该单据编号已经存在','warning');
- return;
- }
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','检查单据编号是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
- //保存信息
- /**
- * 2019-01-25
- * 我对这个方法的实现结果存在严重怀疑,决定重构
- * 有如下疑点:
- * 1、保存完主表,返回结果后,再发起请求去操作子表,如何保证事务的一致性(业务数据一致性)
- * 2、保存完主表后,再通过selectmax的方式去获取主表主键id完全就是看人品的不可靠的思路
- * 修改计划:
- * 2019-01-25修改零售出库相关操作
- * 修改方式,重写url,将主从表操作合并
- *
- *
- * **/
- $("#saveDepotHead").off("click").on("click",function(){
- if(!$('#depotHeadFM').form('validate')){
- return;
- }
- else {
- //如果初始编号被修改了,就要判断单据编号是否存在
- if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
- //调用查询单据编号是否重名的方法
- if(checkDepotHeadNumber()){
- return;
- }
- }
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择收货单位!','warning');
- return;
- }
- if(!$('#AccountId').val()){
- $.messager.alert('提示','请选择收款账户!','warning');
- return;
- }
- if (editIndex != undefined) {
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- //进行明细的校验
- if(depotHeadID ==0) {
- //新增模式下
- if (!CheckData("add")) {
- return;
- }
- }
- else {
- //编辑模式下
- if (!CheckData("edit")) {
- return;
- }
- }
- var OrganId = null, ProjectId = null,AllocationProjectId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val())-0;
- var TotalPrice = $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text();
- if($('#OrganId').length){
- OrganId = $('#OrganId').combobox('getValue');
- }
- var accountMoneyList = $("#AccountId").attr("data-accountmoneyarr"); //账户金额列表-多账户
- var accountMoneyArr;
- if(accountMoneyList) {
- accountMoneyList = accountMoneyList.replace("[","").replace("]","").toString();
- var reg=new RegExp("\"","g"); //创建正则RegExp对象
- accountMoneyList = accountMoneyList.replace(reg,""); //替换所有的双引号
- accountMoneyArr = accountMoneyList.split(","); //转为数组
- }
- //零售时候,可以从会员预付款中扣款
- var thisPayType = "现付";
- var SalesmanStr = "";
- var getAccountID = $.trim($("#AccountId").val());
- if($("#AccountId").val() === "many"){ //多账户
- getAccountID = null;
- }
- var infoStr=JSON.stringify({
- Type: listType,
- SubType: listSubType,
- ProjectId: ProjectId,
- AllocationProjectId: AllocationProjectId,
- DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
- Number: $.trim($("#Number").val()),
- LinkNumber: $.trim($("#LinkNumber").val()),
- OperTime: $("#OperTime").val(),
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Salesman: SalesmanStr, //销售人员
- AccountId: getAccountID,
- ChangeAmount: ChangeAmount, //付款/收款
- TotalPrice: TotalPrice, //合计
- PayType: thisPayType, //现付/预付款
- Remark: $.trim($("#Remark").val()),
- AccountIdList: $("#AccountId").attr("data-accountarr"), //账户列表-多账户
- AccountMoneyList: accountMoneyArr ? JSON.stringify(accountMoneyArr) : "", //账户金额列表-多账户
- Discount: $.trim($("#Discount").val()),
- DiscountMoney: $.trim($("#DiscountMoney").val()),
- DiscountLastMoney: $.trim($("#DiscountLastMoney").val()),
- OtherMoney: $.trim($("#OtherMoney").val()), //采购费用、销售费用
- OtherMoneyList: $("#OtherMoney").attr("data-itemarr"), //支出项目列表-涉及费用
- OtherMoneyItem: $("#OtherMoney").attr("data-itemmoneyarr"), //支出项目金额列表-涉及费用
- AccountDay: $("#AccountDay").val() //结算天数
- });
- /**
- * 零售出库,单独操作
- * */
- if(url.indexOf("/depotHead/addDepotHeadAndDetail")>=0){
- addDepotHeadAndDetail(url,infoStr);
- return;
- }else if(url.indexOf("/depotHead/updateDepotHeadAndDetail")>=0){
- updateDepotHeadAndDetail(url,infoStr,preTotalPrice);
- return;
- }
-
- }
- });
-
- //打印单据
- $("#printDepotHeadShow").off("click").on("click",function(){
- var tableString = $("#depotHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event){
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="State"||obj.id=="Number"))
- {
- $("#saveDepotHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber"||obj.id=="searchMaterial"))
- {
- $("#searchBtn").click();
- }
- });
-
- //优惠率输入框事件
- $("#Discount").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountNum = $(this).val();
- var discountMoney = (discountNum/100*totalPrice).toFixed(2);
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#DiscountMoney").val(discountMoney); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //优惠金额输入框事件
- $("#DiscountMoney").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountMoney = $(this).val();
- var discount = (discountMoney/totalPrice).toFixed(2)*100;
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#Discount").val(discount); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //付款、收款输入框事件
- $("#ChangeAmount").off("keyup").on("keyup",function(){
- var discountLastMoney = $("#DiscountLastMoney").val();
- var changeAmount = $(this).val();
- var debtMoney = (discountLastMoney - changeAmount).toFixed(2);
- $("#Debt").val(debtMoney); //本次欠款
- });
-
- //多账户结算窗口弹出事件
- function depotHeadAccountDlgFun(){
- $('#depotHeadAccountDlg').dialog('open').dialog('setTitle','
多账户结算');
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").remove(); //先移除输入栏目
- $("#accountMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#depotHeadAccountDlg .tabs-tmp .account-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#depotHeadAccountDlg .tabs-tmp tbody").html();
- var accountDlgHead = $("#depotHeadAccountDlg .account-head-tmp");
- accountDlgHead.after(contentTmp);
- }
-
- //获取账户信息
- function accountDlgFun() {
- var options = "";
- if(accountList !=null){
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- }
- $(".account-id-dlg").empty().append("").append(options);
- }
- }
- accountDlgFun(); //获取账户信息
- $("#depotHeadAccountDlg .tabs-tmp").hide(); //隐藏模板
-
- //账户金额输入框事件-多账户
- $("#depotHeadAccountDlg .account-dlg .account-money-dlg").off("keyup").on("keyup",function(){
- var totalAccoutNum = 0;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var eachAccountMoney = $(this).find(".account-money-dlg").val()-0;
- totalAccoutNum += eachAccountMoney;
- });
- $("#accountMoneyTotalDlg").text(totalAccoutNum);
- });
-
- //结算多账户列表的切换事件
- $("#depotHeadAccountDlg .account-dlg .account-id-dlg").off("change").on("change",function(){
- var selectAccount = $(this).children('option:selected').text();
- if(selectAccount === ""){
- var thisMoneyDom = $(this).closest(".account-content-tmp").find(".account-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text() - 0;
- $("#accountMoneyTotalDlg").text(accountMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //账户为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveDepotHeadAccountDlg").off("click").on("click", function(){
- //完成多账户的json数据存储
- var accountArr = []; //账户id数组
- var accountMoneyArr = []; //账户金额数组
- var errorIndex = -1;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var thisAccId = $(this).find(".account-id-dlg").val();
- var thisAccMoney = $(this).find(".account-money-dlg").val();
- if(!thisAccId && thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && !thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && thisAccMoney) {
- accountArr.push(thisAccId);
- accountMoneyArr.push(thisAccMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var discountLastMoneyNum =$("#DiscountLastMoney").val()-0; //优惠后金额
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text()-0; //本次付款或者收款
- if(accountMoneyTotal===0){
- $.messager.alert('错误提示',"请填写金额后保存",'warning');
- return;
- }
- if(accountArr.length && accountMoneyArr.length) {
- $("#AccountId").attr("data-accountArr",JSON.stringify(accountArr)).attr("data-accountMoneyArr",JSON.stringify(accountMoneyArr)); //json数据存储
- }
- $("#ChangeAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
- $("#Debt").val((discountLastMoneyNum-accountMoneyTotal).toFixed(2)); //本次欠款
- $("#depotHeadAccountDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#AccountId").attr("data-accountArr")){
- $("#depotHeadAccountDlg").dialog('close');
- }
- else {
- $("#depotHeadAccountDlg").dialog('close');
- $("#AccountId").val("").removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- }
- //多账户-取消按钮
- $("#cancelDepotHeadAccountDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //多账户-右上角的关闭按钮
- $("#depotHeadAccountDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
- }
- //点击多账户,弹出输入框
- $("#AccountId").off("change").on("change",function(){
- var selectText = $(this).children('option:selected').text();
- if(selectText === "多账户"){
- $("#ChangeAmount").prop("readonly","readonly");
- depotHeadAccountDlgFun();
- $(".many-account-ico").show(); //显示多账户小图标
- }
- else{
- $(this).removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- });
-
- //结算账户-多账户小图标-点击事件
- $(".many-account-ico").off("click").on("click",function(){
- depotHeadAccountDlgFun();
- //给弹窗赋值-多账户数据
- var accountArr = $("#AccountId").attr("data-accountArr");
- accountArr = JSON.parse(accountArr);
- var accountMoneyArr = $("#AccountId").attr("data-accountMoneyArr");
- accountMoneyArr = JSON.parse(accountMoneyArr);
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".account-id-dlg").val(accountArr[index]);
- $(this).find(".account-money-dlg").val(accountMoneyArr[index]);
- });
- $("#accountMoneyTotalDlg").text($("#ChangeAmount").val());
- });
-
- //点击采购费用、销售费用的事件
- $(".other-money-ico").off("click").on("click",function(){
- $('#otherMoneyDlg').dialog('open').dialog('setTitle','
'+ listSubType +'费用');
- $("#otherMoneyDlg .money-dlg .money-content-tmp").remove(); //先移除输入栏目
- $("#otherMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#otherMoneyDlg .tabs-tmp .money-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#otherMoneyDlg .tabs-tmp tbody").html();
- var moneyDlgHead = $("#otherMoneyDlg .money-head-tmp");
- moneyDlgHead.after(contentTmp);
- }
-
- //获取支出项目信息
- function moneyDlgFun() {
- var options = "";
- if(outItemList !=null){
- for(var i = 0 ;i < outItemList.length;i++) {
- var money = outItemList[i];
- options += '';
- }
- $(".money-id-dlg").empty().append("").append(options);
- }
- }
- moneyDlgFun(); //获取支出项目信息
- $("#otherMoneyDlg .tabs-tmp").hide(); //隐藏模板
-
- //支出项目的金额输入框事件
- $("#otherMoneyDlg .money-dlg .other-money-dlg").off("keyup").on("keyup",function(){
- var totalMoneyNum = 0;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var eachOtherMoney = $(this).find(".other-money-dlg").val()-0;
- totalMoneyNum += eachOtherMoney;
- });
- $("#otherMoneyTotalDlg").text(totalMoneyNum);
- });
-
- //支出项目列表的切换事件
- $("#otherMoneyDlg .money-dlg .money-id-dlg").off("change").on("change",function(){
- var selectItem = $(this).children('option:selected').text();
- if(selectItem === ""){
- var thisMoneyDom = $(this).closest(".money-content-tmp").find(".other-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text() - 0;
- $("#otherMoneyTotalDlg").text(otherMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //支出项目为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveOtherMoneyDlg").off("click").on("click", function(){
- //完成支出项目的json数据存储
- var itemArr = []; //支出项目id数组
- var itemMoneyArr = []; //支出项目金额数组
- var errorIndex = -1;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var thisId = $(this).find(".money-id-dlg").val();
- var thisMoney = $(this).find(".other-money-dlg").val();
- if(!thisId && thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && !thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && thisMoney) {
- itemArr.push(thisId);
- itemMoneyArr.push(thisMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text()-0; //合计金额
- if(otherMoneyTotal === 0){ //0的时候清空缓存数据
- $("#OtherMoney").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr");
- }
- if(itemArr.length && itemMoneyArr.length) {
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
- $("#OtherMoney").val(otherMoneyTotal); //给采购费用、销售费用赋值
- $("#otherMoneyDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#OtherMoney").attr("data-itemArr")){
- $("#otherMoneyDlg").dialog('close');
- }
- else {
- $("#otherMoneyDlg").dialog('close');
- $("#OtherMoney").val("").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr"); //将下拉置空并把缓存参数清空
- }
- }
- //费用-取消按钮
- $("#cancelOtherMoneyDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //费用-右上角的关闭按钮
- $("#otherMoneyDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
-
- //给弹窗赋值-采购费用、销售费用数据
- var itemArr = $("#OtherMoney").attr("data-itemArr");
- itemArr = JSON.parse(itemArr);
- var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr");
- itemMoneyArr = JSON.parse(itemMoneyArr);
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".money-id-dlg").val(itemArr[index]);
- if(itemMoneyArr[index]!="undefined"){
- $(this).find(".other-money-dlg").val(itemMoneyArr[index]);
- }
- });
- $("#otherMoneyTotalDlg").text($("#OtherMoney").val());
- });
-}
-
-function showDepotHeadDetails(pageNo,pageSize){
- var materialParam = $.trim($("#searchMaterial").val());
- var beginTime = $.trim($("#searchBeginTime").val());
- var endTime = $.trim($("#searchEndTime").val());
- if(beginTime) {
- beginTime = beginTime + ' 00:00:00';
- }
- if(endTime) {
- endTime = endTime + ' 23:59:59';
- }
- $.ajax({
- type: "get",
- url: "/depotHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- subType: listSubType,
- state: $.trim($("#searchState").val()),
- number: $.trim($("#searchNumber").val()),
- beginTime: beginTime,
- endTime: endTime,
- materialParam: materialParam,
- depotIds: depotString
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#depotHeadFM .datagrid-body");
- var footer =$("#depotHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
- //点击商品下拉框,自动加载数量、单价、金额
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //点击库存文本框,字段计算库存
- body.find("[field='Stock']").find(input).off("click").on("click",function(){
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- var monthTime = getNowFormatMonth();
- if(depotId && mId){
- var ratio = body.find("[field='Unit']").find(input).attr("data-ratio");
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //在新增的时候,这个ratio有值;在编辑的时候,这个ratio为undefined
- var type = "click"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratio, type);
- }
- else{
- body.find("[field='Stock']").find(input).val(0).attr("data-stock",0); //加载库存数据
- }
- });
- //修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计
- body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber =$(this).val()-0; //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
-
- });
- //修改单价,自动计算金额和合计
- body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice =$(this).val()-0; //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击单价,自动提示参考价格列表
- body.find("[field='UnitPrice']").find(input).off("click").on("click",function(){
- var self = this;
- var mValue = body.find("[field='MaterialId'] .combo-value").attr("value"); //获取选中的商品id
- if(!mValue) {
- return;
- }
- else {
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mValue - 0
- },
- success: function(res){
- if(res && res.rows && res.rows[0]) {
- var retailPrice = res.rows[0].RetailPrice;
- var presetPriceOne = res.rows[0].PresetPriceOne;
- var presetPriceTwo = res.rows[0].PresetPriceTwo;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- 批发价:" + presetPriceTwo + "
";
- temp +="- 零售价:" + retailPrice + "
";
- temp +="
";
- temp +="
";
- if($('.price-list').length){
- $('.price-list').remove(); //如果存在价格列表先移除
- }
- else {
- if(presetPriceTwo != undefined){ //多单位的商品
- $(self).after(temp); //加载列表信息
- }
- }
- $('.price-list ul li').off("click").on("click",function(){
- var price = $(this).text();
- price = price.substring(price.indexOf(":") + 1);
- $(self).val(price);
- $(self).keyup(); //模拟键盘操作
- $('.price-list').remove(); //移除价格列表
- });
- //点击空白处移除价格列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.price-list').remove(); //移除价格列表
- });
- }
- },
- error: function(){
- $.messager.alert('错误提示','查询商品信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- //修改含税单价,自动计算单价、金额、税额、价税合计和合计
- body.find("[field='TaxUnitPrice']").find(input).off("keyup").on("keyup",function(){
- var TaxUnitPrice =$(this).val()-0; //含税单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var UnitPrice = TaxUnitPrice/(1+taxRate/100); //计算单价
- body.find("[field='UnitPrice']").find(input).val((UnitPrice).toFixed(2)); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改金额,自动计算单价、税额、价税合计和合计
- body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var AllPrice =$(this).val()-0; //金额
- var UnitPrice = (AllPrice/OperNumber).toFixed(2);
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税率,自动计算含税单价、税额、价税合计和合计
- body.find("[field='TaxRate']").find(input).off("keyup").on("keyup",function(){
- var taxRate =$(this).val()-0; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税额,自动计算税率、含税单价、价税合计和合计
- body.find("[field='TaxMoney']").find(input).off("keyup").on("keyup",function(){
- var taxMoney =$(this).val()-0; //税额
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = taxMoney/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改价税合计,自动计算税率、含税单价、税额和合计
- body.find("[field='TaxLastMoney']").find(input).off("keyup").on("keyup",function(){
- var taxLastMoney =$(this).val()-0; //价税合计
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = (taxLastMoney-AllPrice)/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
-
- //加载税率
- if(thisTaxRate) {
- body.find("[field='TaxRate']").find(input).val(thisTaxRate);
- }
- else {
- body.find("[field='TaxRate']").find(input).val(0); //默认为0
- }
-
- //在商品类型加载 组装件、普通子件
- var mType = body.find("[field='MType']");
- var rowListLength = mType.find(input).closest(".datagrid-row").attr("datagrid-row-index");
- var mTypeValue = "组合件";
- if(rowListLength > 0){
- mTypeValue = "普通子件";
- }
- },500);
-}
-
-//结束编辑
-function endEditing() {
- if (editIndex == undefined) { return true }
- if ($('#materialData').datagrid('validateRow', editIndex)) {
- //仓库信息
- var edDepot = $('#materialData').datagrid('getEditor', {index:editIndex,field:'DepotId'});
- var DepotName = $(edDepot.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName;
- //商品信息
- var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'});
- var MaterialName = $(edMaterial.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName;
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#materialData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append(){
- if (endEditing()) {
- $('#materialData').datagrid('appendRow', {DepotId:defDepotId});
- editIndex = $('#materialData').datagrid('getRows').length - 1;
- $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function batchDel(){
- /**
- * 重写一下删除的逻辑
- * 获取所有选中行,直接从列表中移除
- * 点击保存时,将需要后台删除的数据提交到服务器
- * **/
- /**
- * create by: qiankunpingtai
- * create time: 2019/3/20 16:26
- * description:
- * 这个地方比较坑的,花了一个多小时才搞明白为什么
- * 1、删除之前必须先调用endEditing结束编辑
- * 2、如果只是调用endEditing结束编辑那么正在编辑行的被选中状态会被去掉
- * 所以要在调用endEditing先获取选中的行
- */
- //如果编辑的行一开始是选中状态,结束编辑后仍然是选中状态
- var row = $('#materialData').datagrid('getChecked');
- if (endEditing()) {
- if (row.length == 0) {
- $.messager.alert('删除提示', '没有记录被选中!', 'info');
- return;
- }
- if (row.length > 0) {
- $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条单据信息吗?', function (r) {
- if (r) {
- for (var i = 0; i < row.length; i++) {
- $('#materialData').datagrid('deleteRow', $('#materialData').datagrid("getRowIndex", row[i]));
- }
- }
- });
- }
- }
-}
-function removeit(){
- if (editIndex == undefined) { return }
- $('#materialData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#materialData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData(type) {
- var change = $('#materialData').datagrid('getChanges').length;
- if(type =="add" && !change) {
- $.messager.alert('提示','请输入明细信息!','warning');
- return false;
- }
- var row = $('#materialData').datagrid('getRows');
- if(!row.length){
- $.messager.alert('提示',"请输入明细信息!",'info');
- return false;
- }
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if (row[i].DepotId == "" || row[i].MaterialId == "" || row[i].OperNumber == "" || row[i].UnitPrice === "" || row[i].AllPrice === "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-
-
-/**
- * 新增单据主表及单据子表
- * */
-function addDepotHeadAndDetail(url,infoStr){
- var inserted = null;
- if(pageType === "skip") {
- inserted = $("#materialData").datagrid('getChanges', "updated");
- } else {
- inserted = $("#materialData").datagrid('getChanges', "inserted");
- }
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated)
- }),
- success: function (tipInfo){
-
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
-
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
-
-
- });
-}
-/**
- * 修改单据主表及单据子表
- * */
-function updateDepotHeadAndDetail(url,infoStr,preTotalPrice){
- var inserted = $("#materialData").datagrid('getChanges', "inserted");
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- id:url.substring(url.lastIndexOf("?id=")+4,url.length),
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- preTotalPrice:preTotalPrice
- }),
- success: function (tipInfo){
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
- if (endEditing()) {
- $('#materialData').datagrid('acceptChanges');
- }
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-
-
-
diff --git a/erp_web/js/pages/materials/purchase_in_list.js b/erp_web/js/pages/materials/purchase_in_list.js
deleted file mode 100644
index 4e9a757a..00000000
--- a/erp_web/js/pages/materials/purchase_in_list.js
+++ /dev/null
@@ -1,2442 +0,0 @@
-//初始化界面
-var defDepotId = null;
-var kid = sessionStorage.getItem("userId");
-var pageType = getUrlParam('t'); //获取页面类型传值
-var depotList = null;
-var depotID = null;
-var supplierList = null;
-var supplierID = null;
-var personList = null;
-var personID = null;
-var ProjectSearch=null;
-var userBusinessList=null;
-var userdepot=null;
-var url;
-var depotHeadID = 0;
-var preTotalPrice = 0; //前一次加载的金额
-var orgDepotHead = "";
-var editIndex = undefined;
-/**默认编号有意义吗,不如空着吧*/
-var orgDefaultId=''; //单位默认编号
-var orgDefaultList; //存储查询出来的会员列表
-var accountList; //账户列表
-var outItemList; //支出项目列表
-var thisTaxRate = 0; //当前税率,选择供应商或者客户的时候设置
-var oldNumber = ""; //编辑前的单据编号
-var oldId = 0; //编辑前的单据Id
-var otherColumns = true; //明细中的‘别名’列是否显示
-var btnEnableList = getBtnStr(); //获取按钮的权限
-var mPropertyList = ""; //商品属性列表
-var defaultAccountId = 0; //默认账户id
-//改变宽度和高度
-$("#searchPanel").panel({width:webW-2});
-$("#tablePanel").panel({width:webW-2});
-var listTitle = "采购入库列表"; //单据标题
-var depotString = "|"; //店铺id列表
-var listType ="入库";//入库 出库
-var listSubType = "采购"; //采购 销售等
-var payTypeTitle = "付款"; //付款 收款
-var organUrl = "/supplier/findBySelect_sup"; //组织数据接口地址
-var amountNum ="CGRK";//单据编号开头字符
-$(function(){
- //初始化系统基础信息
- initSystemData_UB();
- initSelectInfo_UB();
- initSystemData_depot();
- initSelectInfo_depot();
- initSystemData_person();
- initSelectInfo_person();
- initSystemData_account();
- initSelectInfo_account();
- initSupplier(); //供应商
- initSalesman(); //销售人员
- initOutItemList(); //初始化支出项目
- initMProperty(); //初始化商品属性
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
-});
-//初始化系统基础信息
-function initSystemData_UB(){
- $.ajax({
- type:"get",
- url: "/userBusiness/getBasicData",
- data: ({
- KeyId:kid,
- Type:"UserDepot"
- }),
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if (res && res.code === 200) {
- userBusinessList = res.data.userBusinessList;
- }
- else {
- userBusinessList = null;
- }
- }
- });
-
-}
-//初始化页面选项卡
-function initSelectInfo_UB(){
-
- if(userBusinessList !=null)
- {
- if(userBusinessList.length>0)
- {
- //用户对应的仓库列表 [1][2][3]...
- userdepot =userBusinessList[0].value;
- }
- }
-}
-
-
-//初始化系统基础信息
-function initSystemData_depot(){
- $.ajax({
- type:"get",
- url: "/depot/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200){
- depotList = res.data;
- } else {
- $.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error');
- return;
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_depot(){
- var options = "";
-
- if(depotList !=null)
- {
- options = "";
- for(var i = 0 ;i < depotList.length;i++)
- {
- var depot = depotList[i];
-
- if(userdepot!=null)
- {
- if(userdepot.indexOf("["+depot.id+"]")!=-1)
- {
- if(depot.isDefault){
- defDepotId = depot.id;
- }
- options += '';
- depotString = depotString + depot.id + ",";
- }
- }
- if(depot.type === 1){
- depotString = depotString + depot.id + ",";
- }
- }
- depotString = depotString.substring(1, depotString.length-1);
- $("#ProjectId").empty().append(options);
- $("#AllocationProjectId").empty().append(options);
- $("#searchProjectId").empty().append('').append(options);
- }
-}
-
-//初始化供应商、客户、散户信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onLoadSuccess: function(res) {
- var data = $(this).combobox('getData');
- for(var i = 0; i<= data.length; i++){
- if(data && data[i] && data[i].supplier === "非会员"){
- orgDefaultId = data[i].id;
- }
- }
- },
- onSelect: function(rec){
- $.ajax({
- type:"get",
- url: "/supplier/findById",
- data: {
- supplierId: rec.id
- },
- dataType: "json",
- success: function (res){
- if(res && res.code === 200) {
- if(res.data && res.data[0]){
- thisTaxRate = res.data[0].taxRate; //设置当前的税率
- }
- }
- },
- error:function(){
-
- }
- });
- }
- });
-}
-
-//初始化销售人员
-function initSalesman(){
- $('#Salesman').combobox({
- url: "/person/getPersonByNumType?type=1",
- valueField:'id',
- textField:'name',
- multiple: true
- });
-}
-
-//初始化收入项目列表
-function initOutItemList(){
- $.ajax({
- type:"get",
- url: "/inOutItem/findBySelect?type=out",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res){
- if(res){
- outItemList = res;
- }
- },
- error:function(){
-
- }
- });
-}
-
-//初始化商品属性
-function initMProperty(){
- $.ajax({
- type: "get",
- url: "/materialProperty/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- name: ""
- }),
- currentPage: 1,
- pageSize: 100
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- var thisRows = res.data.page.rows;
- for (var i = 0; i < thisRows.length; i++) {
- if (thisRows[i].enabled) {
- mPropertyList += thisRows[i].nativename + ",";
- }
- }
- if (mPropertyList) {
- mPropertyList = mPropertyList.substring(0, mPropertyList.length - 1);
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化系统基础信息
-function initSystemData_person(){
- $.ajax({
- type:"get",
- url: "/person/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- personList = res.data.personList;
- }
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_person(){
- var options1 = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="仓管员")
- {
- options1 += '';
- }
- }
- $("#HandsPersonId").empty().append(options1);
- }
-}
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null){
- options = "";
- options += "";
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- if(account.isdefault) {
- defaultAccountId = account.id; //给账户赋值默认id
- }
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#depotHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- if(pageType === "skip") {
- var oldRowInfo = sessionStorage.getItem("rowInfo");
- editDepotHead(oldRowInfo); //自动弹出编辑框,带缓存数据
- }
- var hideType = undefined;
- var isHiddenStatus = true;
- if(payTypeTitle === "隐藏"){
- hideType = true; //隐藏当前列
- }
- var tableToolBar = [
- {
- id:'addDepotHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addDepotHead();
- }
- },
- {
- id:'deleteDepotHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteDepotHead();
- }
- }
- ];
- //如果允许的按钮列表中存在就显示,3-代表审核|反审核的权限
- if(btnEnableList && btnEnableList.indexOf(3)>-1){
- isHiddenStatus = false; //显示
- tableToolBar.push({
- id:'okDepotHead',
- text:'审核',
- iconCls:'icon-ok',
- handler:function() {
- setStatusFun();
- }
- },
- {
- id:'undoDepotHead',
- text:'反审核',
- iconCls:'icon-undo',
- handler:function() {
- setUnStatusFun();
- }
- });
- }
- else {
- isHiddenStatus = true; //隐藏
- }
- var isShowLastMoneyColumn = false; //是否显示优惠后金额和价税合计,true为隐藏,false为显示
- var isShowOrganNameColumn = false; //是否显示供应商、客户等信息,true为隐藏,false为显示
- var organNameTitle = "供应商名称"; //组织名称标题
- var opWidth = 90; //操作宽度
- var opTitle = ""; //跳转按钮的标题
- $('#tableData').datagrid({
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: true,
- //交替出现背景
- striped : true,
- pageSize: 10,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:opWidth,
- formatter:function(value, rec,index) {
- var str = '';
- var orgId = rec.organid? rec.organid:0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
- { title: '单据编号',field: 'number',width:135, formatter:function (value,rec) {
- if(rec.linknumber) {
- return value + "[转]";
- } else {
- return value;
- }
- }
- },
- { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
- if(value) {
- return value.replace(",",",");
- }
- }
- },
- { title: '单据日期',field: 'opertimeStr',width:130},
- { title: '操作员',field: 'operpersonname',width:60},
- { title: '金额合计',field: 'totalprice',width:60},
- { title: '含税合计',field: 'totaltaxlastmoney',hidden:isShowLastMoneyColumn,width:60,formatter:function(value,rec){
- return (rec.discountmoney + rec.discountlastmoney).toFixed(2);
- }
- },
- { title: '优惠后金额',field: 'discountlastmoney',hidden:isShowLastMoneyColumn,width:80},
- { title: payTypeTitle,field: 'changeamount',width:50,hidden:hideType},
- { title: '状态',field: 'status',hidden:isHiddenStatus, width:70,align:"center",formatter:function(value){
- if(value === "0") {
- return "未审核";
- } else if(value === "1") {
- return "已审核";
- } else if(value === "2") {
- }
- }
- }
- ]],
- toolbar:tableToolBar,
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//查找库存的方法
-function findStockNumById(depotId, mId, monthTime, body, input, ratio, type){
- var thisRatio = 1; //比例
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (rec) {
- if(rec && rec.code === 200 && rec.data && rec.data[0]) {
- var loadRatio = 1; //在单位输入框上面加载比例字段
- if(rec.data[0].unit) { //如果存在计量单位信息
- loadRatio = 1;
- }
- else{
- var unitName = rec.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- thisRatio = unitName.substring(unitName.indexOf(":")+1).replace(")","");
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- unitSetInput = rec.data[0].firstinunit;
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = thisRatio;
- }
- }
- //查询库存
- $.ajax({
- type: "get",
- url: '/depotItem/findStockNumById',
- data:{
- projectId: depotId,
- materialId: mId
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if (res.data && res.data.page && res.data.page[0]) {
- var thisStock = res.data.page[0].thisSum;
- if (type == "select") { //选择下拉框的时候
- if (ratio != undefined && ratio != 1) {
- loadRatio = ratio;
- }
- }
- else if (type == "click") { //点击库存的时候
- if (ratio != undefined) {
- loadRatio = ratio;
- }
- }
- thisStock = (thisStock / loadRatio).toFixed(2);
- body.find("[field='Stock']").find(input).val(thisStock).attr("data-stock", res.data.page[0].thisSum); //加载库存数据
- }
- else {
- body.find("[field='Stock']").find(input).val(0).attr("data-stock", 0); //加载库存数据
- }
- body.find("[field='Stock']").find(input).prop("readonly", "readonly"); //设置库存数据为只读
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
- }
- },
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- }
- });
-}
-//优惠率、合计的统计方法
-function statisticsFun(body,UnitPrice,OperNumber,footer,taxRate){
- var TotalPrice = 0;
- var taxLastMoneyTotal = 0;
- //金额的合计
- body.find("[field='AllPrice']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + UnitPrice*OperNumber;
- footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); //金额的合计
- //价税合计的总计
- body.find("[field='TaxLastMoney']").each(function(){
- if($(this).find("div").text()!==""){
- taxLastMoneyTotal = taxLastMoneyTotal + (parseFloat($(this).find("div").text().toString())-0);
- }
- });
- taxLastMoneyTotal = taxLastMoneyTotal + (UnitPrice*OperNumber*(1+taxRate/100));
- footer.find("[field='TaxLastMoney']").find("div").text((taxLastMoneyTotal).toFixed(2)); //价税合计的页脚总计
- var discount = $("#Discount").val(); //优惠率
- var discountMoney = (taxLastMoneyTotal*discount/100).toFixed(2);
- $("#DiscountMoney").val(discountMoney);//优惠金额
- var discountLastMoney = (taxLastMoneyTotal*(1-discount/100)).toFixed(2)
- $("#DiscountLastMoney").val(discountLastMoney);//优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
-
-}
-//初始化表格数据-商品列表-编辑状态
-function initTableData_material(type,TotalPrice){
- var body,footer,input; //定义表格和文本框
- var ratio = 1; //比例-品名专用
- var ratioDepot = 1; //比例-仓库用
- var monthTime = getNowFormatMonth();
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var depotHeadName = ""; //仓库名称
- var depotUrl = ""; //仓库接口地址
- var depotTextField = ""; //仓库下拉名称
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var anotherDepotUrl = ""; //对方仓库接口地址
- var anotherDepotTextField = "";
- depotHeadName = "仓库名称";
- depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- depotTextField = "depotName";
- var isShowTaxColumn = false; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialData').datagrid({
- height:245,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: '商品类型',field: 'MType',editor:'validatebox',hidden:isShowMaterialTypeColumn,width:80},
- { title: depotHeadName, field: 'DepotId', editor: 'validatebox', width: 90,
- formatter: function (value, row, index) {
- return row.DepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: depotTextField,
- method: 'get',
- url: depotUrl,
- onSelect:function(rec){
- var depotId = rec.id;
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- if(mId){
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratioDepot, type);
- }
- }
- }
- }
- },
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialId',width:230,
- formatter:function(value,row,index){
- return row.MaterialName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'MaterialName',
- method:'get',
- url: "/material/findBySelect",
- panelWidth: 300, //下拉框的宽度
- //全面模糊匹配,过滤字段
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onBeforeLoad: function(param){
- param.mpList = mPropertyList; //商品属性
- },
- onSelect:function(rec){
- if(rec) {
- var mId = rec.Id;
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (res) {
- if(res && res.code === 200 && res.data && res.data[0]) {
- var retailPrice = res.data[0].retailprice-0; //零售价格
- var presetPriceOne = res.data[0].presetpriceone-0; //预计采购价
- var presetPriceTwo = res.data[0].presetpricetwo-0; //批发价
- var firstInUnit = res.data[0].firstinunit; //首选入库单位
- var firstOutUnit = res.data[0].firstoutunit; //首选出库单位
- var basicPresetPriceOne = ""; //多单位-入库-基础价格
- var basicPresetPriceTwo = ""; //多单位-出库-基础价格
- var retailPriceOne = ""; //多单位-入库-零售价格
- var otherPresetPriceOne = ""; //多单位-入库-其他价格
- var otherPresetPriceTwo = ""; //多单位-出库-其他价格
- var retailPriceTwo = ""; //多单位-出库-零售价格
- var basicUnit = ""; //基础单位
- var otherUnit = ""; //其他单位
- if(!res.data[0].unit){
- var ps = res.data[0].pricestrategy;
- var psObj = JSON.parse(ps);
- basicPresetPriceOne = psObj[0].basic.PresetPriceOne-0;
- basicPresetPriceTwo = psObj[0].basic.PresetPriceTwo-0;
- retailPriceOne = psObj[0].basic.RetailPrice-0;
- otherPresetPriceOne = psObj[1].other.PresetPriceOne-0;
- otherPresetPriceTwo = psObj[1].other.PresetPriceTwo-0;
- retailPriceTwo = psObj[1].other.RetailPrice-0;
- basicUnit = psObj[0].basic.Unit;
- otherUnit = psObj[1].other.Unit;
- }
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- if(res.data[0].unit){ //如果存在计量单位信息
- ratio = 1; //重置比例为1
- body.find("[field='Unit']").find(input).val(res.data[0].unit); //设置-计量单位信息
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- body.find("[field='Unit']").find(input).off("click"); //移除点击事件
- body.find("[field='Unit']").find(input).attr("data-ratio",ratio); //修改比例缓存信息
- }
- else {
- var unitName = res.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- var loadRatio = 1; //在单位输入框上面加载比例字段
- unitSetInput = res.data[0].firstinunit; //给单位文本框赋值
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = ratio;
- }
- body.find("[field='Unit']").find(input).val(unitSetInput).attr("data-ratio", loadRatio); //设置-首选单位
-
- body.find("[field='Unit']").find(input).off("click").on("click",function(){
- if(basicUnit && otherUnit) {
- var self = this;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- " + basicUnit + "
";
- temp +="- " + otherUnit + "
";
- temp +="
";
- temp +="
";
- if($('.unit-list').length){
- $('.unit-list').remove(); //如果存在计量单位列表先移除
- }
- else {
- $(self).after(temp); //加载列表信息
- }
- //计量单位列表的单击事件
- $('.unit-list ul li').off("click").on("click",function(){
- var unit = $(this).text();
- var thisRatio = $(this).attr("data-ratio"); //获取比例
- $(self).val(unit).attr("data-ratio", thisRatio);
- $(self).keyup(); //模拟键盘操作
- $('.unit-list').remove(); //移除计量单位列表
- var stock = body.find("[field='Stock']").find(input).attr("data-stock"); //从缓存中取值
- var type = $(this).attr("data-type");
- var UnitPrice = 0;
- if(type === "basic"){
- UnitPrice = basicPresetPriceOne;
- body.find("[field='Stock']").find(input).val(stock); //修改库存
- }
- else if(type === "other"){
- UnitPrice = otherPresetPriceOne;
- body.find("[field='Stock']").find(input).val((stock/ratio).toFixed(2)); //修改库存
- }
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //获取数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击空白处移除计量单位列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.unit-list').remove(); //移除计量单位列表
- });
- }
- });
- }
- var detailPrice = 0; //明细列表-单价
- if(res.data[0].unit) { //如果存在计量单位信息
- detailPrice = presetPriceOne;
- }
- else {
- if (firstInUnit == basicUnit) {
- detailPrice = basicPresetPriceOne;
- }
- else if (firstInUnit == otherUnit) {
- detailPrice = otherPresetPriceOne;
- }
- }
- body.find("[field='OperNumber']").find(input).val(1); //数量初始化为1
- //单价和总价赋值
- if(!detailPrice) {
- detailPrice = 0;
- }
- body.find("[field='UnitPrice']").find(input).val(detailPrice);
- body.find("[field='AllPrice']").find(input).val(detailPrice);
- var taxRate = body.find("[field='TaxRate']").find(input).val()-0; //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((detailPrice*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,detailPrice,1,footer,taxRate);
-
- //查询库存信息
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- if(depotId) {
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, loadRatio, type);
- }
- }
- },
- error: function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- }
- });
- }
- }
- }
- }
- },
- { title: '库存',field: 'Stock',editor:'validatebox',width:70},
- { title: anotherDepotHeadName, field: 'AnotherDepotId',editor:'validatebox',hidden:isShowAnotherDepot,width:90,
- formatter: function (value, row, index) {
- return row.AnotherDepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: anotherDepotTextField,
- method: 'get',
- url: anotherDepotUrl
- }
- }
- },
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率(%)',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batchDel(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = 0;
- var TaxLastMoney = 0;
- var DiscountMoney = $("#DiscountMoney").val()-0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoney").val()-0; //优惠后金额
- if(type === "edit") {
- AllPrice = TotalPrice;
- TaxLastMoney = DiscountMoney + DiscountLastMoney;
- }
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": TaxLastMoney
- });
- data.footer = array;
- $("#materialData").datagrid('loadData',data);
- //如果是订单跳转到采购或销售
- if(pageType === "skip") {
- var skipList = $("#depotHeadFM .datagrid-body tr");
- //逐条自动点击每行数据
- skipList.each(function (i) {
- setTimeout(function () {
- skipList.eq(i).find("[field='Stock']").click();
- },(i+1)*1000);
- });
- }
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//初始化表格数据-商品列表-查看状态
-function initTableData_material_show(TotalPrice){
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var depotHeadName = ""; //仓库的列的标题
- depotHeadName = "仓库名称";
- var isShowTaxColumn = false; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialDataShow').datagrid({
- height:245,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- onClickRow: onClickRow,
- columns:[[
- { title: '商品类型',field: 'MType',width:80, hidden:isShowMaterialTypeColumn},
- { title: depotHeadName,field: 'DepotName',editor:'validatebox',width:90},
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialName',width:230},
- { title: anotherDepotHeadName,field: 'AnotherDepotName',hidden:isShowAnotherDepot,width:90},
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validattebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = TotalPrice;
- var DiscountMoney = $("#DiscountMoneyShow").text() - 0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoneyShow").text() - 0; //优惠后金额
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": DiscountMoney + DiscountLastMoney
- });
- data.footer = array;
- $("#materialDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showDepotHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除单据信息
-function deleteDepotHead(depotHeadID, thisOrganId, totalPrice, status){
- if(status == "1" || status == "2") {
- $.messager.alert('删除提示','已审核和已转的单据不能删除!','warning');
- return;
- }
- $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
- if (r) {
- $.ajax({
- type:"post",
- // url: "/depotHead/" + depotHeadID + "/delete",
- url: "/depotHead/deleteDepotHeadAndDetail",
- dataType: "json",
- data:{
- id: depotHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
- return;
- }
- });
-
- }
- });
-}
-
-//订单转采购或销售
-function skipDepotHead(index, status){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- if(status == "0" || status == "2") {
- $.messager.alert('提示','未审核和已转的单据禁止操作!','warning');
- } else {
- sessionStorage.setItem("rowInfo", JSON.stringify(rowsdata)); //将单据信息存入缓存中
- }
-}
-
-//批量删除单据信息
-function batDeleteDepotHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条单据信息吗?',function(r)
- {
- if (r) {
- var ids = "";
- for (var i = 0; i < row.length; i++) {
- if (i == row.length - 1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- if (ids) {
- //批量删除
- $.ajax({
- type: "post",
- // url: "/depotHead/batchDelete",
- url: "/depotHead/batchDeleteDepotHeadAndDetail",
- dataType: "json",
- async: false,
- data: ({
- ids: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除单据信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('删除提示','没有能删除的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量审核
-function setStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('审核确认','确定要审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: "1",
- depotHeadIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('审核提示', '审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('审核提示','审核信息异常,请稍后再试!','error');
- return;
- }
- });
- } else {
- $.messager.alert('审核提示','没有能审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量反审核
-function setUnStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('反审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('反审核确认','确定要反审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type: "post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async: false,
- data: ({
- status: "0",
- depotHeadIDs: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('反审核提示', '反审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('反审核提示', '反审核信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('反审核提示','没有能反审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//生成单据编号
-function buildNumber() {
- $.ajax({
- type: "get",
- url: "/depotHead/buildNumber",
- success:function(res){
- if(res && res.code === 200){
- var obj = res.data;
- var defaultNumber = obj.DefaultNumber;
- var newNumber = amountNum + defaultNumber;
- $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
- }
- },
- error:function(){
- $.messager.alert('提示','生成单据编号失败!','error');
- }
- });
-}
-
-//新增信息
-function addDepotHead(){
- $('#depotHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- buildNumber(); //生成单据编号
- //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为0
- $("#Discount").val(0);
- $("#DiscountMoney").val(0);
- $("#DiscountLastMoney").val(0);
- $("#ChangeAmount").val(0);
- $("#Debt").val(0);
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- var addTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgDepotHead = "";
- depotHeadID = 0;
- initTableData_material("add"); //商品列表
- reject(); //撤销下、刷新商品列表
- $("#addOrgan").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加供应商信息');
- $('#supplierFM').form('clear');
- });
-
- $("#addMember").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加会员信息');
- $('#supplierFM').form('clear');
- });
- $("#addCustomer").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加客户信息');
- $('#supplierFM').form('clear');
- });
- url = '/depotHead/addDepotHeadAndDetail';
-}
-
-//编辑信息
-function editDepotHead(index, status){
- if(status == "1" || status == "2") {
- $.messager.alert('编辑提示','已审核和已转的单据不能编辑!','warning');
- return;
- }
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata ='';
- if(Number(index).toString()=='NaN'){
- rowsdata=$.parseJSON(index);
- }else{
- rowsdata=$("#tableData").datagrid("getRows")[index];
- }
- $("#ProjectId").focus().val(rowsdata.projectid);
- var ProjectId=rowsdata.projectid;
- if(ProjectId!='') {
- initSystemData_person(ProjectId);
- initSelectInfo_person();
- }
- var TotalPrice = rowsdata.totalprice; //合计金额
- if(pageType === "skip") { //从订单跳转过来
- buildNumber(); //生成单据编号
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- $("#LinkNumber").val(rowsdata.number); //关联订单号
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- $("#DiscountLastMoney").val(TotalPrice); //优惠后金额
- $("#ChangeAmount").val(TotalPrice).attr("data-changeamount", TotalPrice);
- } else {
- $("#Number").val(rowsdata.number).attr("data-defaultNumber",rowsdata.number);
- $("#OperTime").val(rowsdata.opertimeStr);
- $("#LinkNumber").val(rowsdata.linknumber==undefined?"":rowsdata.linknumber); //关联订单号
- $("#AccountId").val(rowsdata.accountid); //账户Id
- $("#DiscountLastMoney").val(rowsdata.discountlastmoney==undefined?"0.00":rowsdata.discountlastmoney); //优惠后金额
- $("#ChangeAmount").val(rowsdata.changeamount).attr("data-changeamount", rowsdata.changeamount);
- }
- $('#OrganId').combobox('setValue', rowsdata.organid==undefined?'':rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#Remark").val(rowsdata.remark);
- $("#Discount").val(rowsdata.discount==undefined?"0":rowsdata.discount);
- $("#DiscountMoney").val(rowsdata.discountmoney==undefined?"0.00":rowsdata.discountmoney);
- $("#Debt").val(Number((rowsdata.discountlastmoney==undefined?'0.00':rowsdata.discountlastmoney-rowsdata.changeamount)).toFixed(2));
- $("#AccountDay").val(rowsdata.accountday==undefined?"":rowsdata.accountday); //结算天数
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于扣预付款
- $("#AllocationProjectId").val(rowsdata.allocationprojectid);
- oldNumber = rowsdata.number; //记录编辑前的单据编号
- oldId = rowsdata.id; //记录单据Id
- var editTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- depotHeadID = rowsdata.id;
-
- //采购入库、销售出库的多账户加载
- if(rowsdata.accountidlist!=undefined && rowsdata.accountmoneylist!=undefined){
- $("#AccountId").val("many"); //下拉框选中多账户
- var accountArr = rowsdata.accountidlist.split(",");
- var accountMoneyArr = rowsdata.accountmoneylist.split(",");
- accountMoneyArr = changeListFmtPlus(accountMoneyArr) //将数组单个金额中的数值转为正数
-
-
- $("#AccountId").attr("data-accountArr", JSON.stringify(accountArr)).attr("data-accountMoneyArr", JSON.stringify(accountMoneyArr)); //json数据存储
- $(".many-account-ico").show(); //显示多账户的ico图标
- }
-
- //采购入库、销售出库的费用数据加载
- if(rowsdata.othermoneylist &&rowsdata.othermoneyitem){
- $("#OtherMoney").val(rowsdata.othermoney==undefined?"0":rowsdata.othermoney); //采购费用、销售费用
- var itemArr = rowsdata.othermoneylist.split(",");
- var itemMoneyArr = rowsdata.othermoneyitem.split(",");
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
-
- initTableData_material("edit",TotalPrice); //商品列表
- reject(); //撤销下、刷新商品列表
- if(pageType === "skip") {
- url = '/depotHead/addDepotHeadAndDetail'; //如果是从订单跳转过来,则此处为新增的接口
- //jshjshjsh
- $("#depotHeadFM .datagrid-body").find("[field='DepotId']").click();
- } else {
- url = '/depotHead/updateDepotHeadAndDetail?id=' + rowsdata.id; //更新接口
- }
-}
-
-//查看信息
-function showDepotHead(index){
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var manyAccountMoney = 0; //多账户合计-零售
- $("#ProjectIdShow").text(rowsdata.projectName);
- $("#NumberShow").text(rowsdata.number);
- $("#OperTimeShow").text(rowsdata.opertimeStr);
- $('#OrganIdShow').text(rowsdata.organName==undefined?'':rowsdata.organName);
- $("#HandsPersonIdShow").text(rowsdata.handsPersonName);
- if(rowsdata.accountName && rowsdata.accountName!=undefined){
- $("#AccountIdShow").text(rowsdata.accountName); //结算账户
- } else {
- var accountArr = (rowsdata.accountidlist==undefined?"":rowsdata.accountidlist).split(","); //账户id列表
- var accountMoneyArr =(rowsdata.accountmoneylist==undefined?"":rowsdata.accountmoneylist).split(","); //账户金额列表
- var accountIdShow = "";
- for(var j =0;j 查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- depotHeadID = rowsdata.id;
- initTableData_material_show(TotalPrice); //商品列表-查看状态
-
-}
-
-//绑定操作事件
-function bindEvent(){
- showDepotHeadDetails(1,initPageSize); //初始化时自动查询
- //搜索处理
- $("#searchBtn").off("click").on("click",function(){
- showDepotHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh',
- {
- pageNumber:1,
- pageSize:initPageSize
- });
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- //$("#searchProjectId").val("");
- $("#searchState").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //检查单据编号是否存在
- function checkDepotHeadNumber() {
- var thisNumber = $.trim($("#Number").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(thisNumber.length > 0 &&( oldNumber.length ==0 || thisNumber != oldNumber))
- {
- $.ajax({
- type:"get",
- url: "/depotHead/checkIsNumberExist",
- dataType: "json",
- async : false,
- data: ({
- DepotHeadID : oldId,
- Number : thisNumber
- }),
- success: function (tipInfo)
- {
- flag = tipInfo;
- if(tipInfo)
- {
- $.messager.alert('提示','抱歉,该单据编号已经存在','warning');
- return;
- }
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','检查单据编号是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
- //保存信息
- /**
- * 2019-01-25
- * 我对这个方法的实现结果存在严重怀疑,决定重构
- * 有如下疑点:
- * 1、保存完主表,返回结果后,再发起请求去操作子表,如何保证事务的一致性(业务数据一致性)
- * 2、保存完主表后,再通过selectmax的方式去获取主表主键id完全就是看人品的不可靠的思路
- * 修改计划:
- * 2019-01-25修改零售出库相关操作
- * 修改方式,重写url,将主从表操作合并
- *
- *
- * **/
- $("#saveDepotHead").off("click").on("click",function(){
- if(!$('#depotHeadFM').form('validate')){
- return;
- }
- else {
- //如果初始编号被修改了,就要判断单据编号是否存在
- if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
- //调用查询单据编号是否重名的方法
- if(checkDepotHeadNumber()){
- return;
- }
- }
- //输入框提示
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择供应商!','warning');
- return;
- }
- if(!$('#AccountId').val()){
- $.messager.alert('提示','请选择结算账户!','warning');
- return;
- }
- if (editIndex != undefined) {
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- //进行明细的校验
- if(depotHeadID ==0) {
- //新增模式下
- if (!CheckData("add")) {
- return;
- }
- }
- else {
- //编辑模式下
- if (!CheckData("edit")) {
- return;
- }
- }
- var OrganId = null, ProjectId = null,AllocationProjectId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val())-0;
- var TotalPrice = $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text();
- if($('#OrganId').length){
- OrganId = $('#OrganId').combobox('getValue');
- }
- var accountMoneyList = $("#AccountId").attr("data-accountmoneyarr"); //账户金额列表-多账户
- var accountMoneyArr;
- if(accountMoneyList) {
- accountMoneyList = accountMoneyList.replace("[","").replace("]","").toString();
- var reg=new RegExp("\"","g"); //创建正则RegExp对象
- accountMoneyList = accountMoneyList.replace(reg,""); //替换所有的双引号
- accountMoneyArr = accountMoneyList.split(","); //转为数组
- }
- //付款为负数
- ChangeAmount = 0 - ChangeAmount;
- TotalPrice = 0 - TotalPrice;
- if(accountMoneyArr) {
- accountMoneyArr = changeListFmtMinus(accountMoneyArr); //将数组单个金额中的数值转为负数
- }
- //零售时候,可以从会员预付款中扣款
- var thisPayType = "现付";
- var SalesmanStr = "";
- var getAccountID = $.trim($("#AccountId").val());
- if($("#AccountId").val() === "many"){ //多账户
- getAccountID = null;
- }
- var infoStr=JSON.stringify({
- Type: listType,
- SubType: listSubType,
- ProjectId: ProjectId,
- AllocationProjectId: AllocationProjectId,
- DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
- Number: $.trim($("#Number").val()),
- LinkNumber: $.trim($("#LinkNumber").val()),
- OperTime: $("#OperTime").val(),
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Salesman: SalesmanStr, //销售人员
- AccountId: getAccountID,
- ChangeAmount: ChangeAmount, //付款/收款
- TotalPrice: TotalPrice, //合计
- PayType: thisPayType, //现付/预付款
- Remark: $.trim($("#Remark").val()),
- AccountIdList: $("#AccountId").attr("data-accountarr"), //账户列表-多账户
- AccountMoneyList: accountMoneyArr ? JSON.stringify(accountMoneyArr) : "", //账户金额列表-多账户
- Discount: $.trim($("#Discount").val()),
- DiscountMoney: $.trim($("#DiscountMoney").val()),
- DiscountLastMoney: $.trim($("#DiscountLastMoney").val()),
- OtherMoney: $.trim($("#OtherMoney").val()), //采购费用、销售费用
- OtherMoneyList: $("#OtherMoney").attr("data-itemarr"), //支出项目列表-涉及费用
- OtherMoneyItem: $("#OtherMoney").attr("data-itemmoneyarr"), //支出项目金额列表-涉及费用
- AccountDay: $("#AccountDay").val() //结算天数
- });
- /**
- * 零售出库,单独操作
- * */
- if(url.indexOf("/depotHead/addDepotHeadAndDetail")>=0){
- addDepotHeadAndDetail(url,infoStr);
- return;
- }else if(url.indexOf("/depotHead/updateDepotHeadAndDetail")>=0){
- updateDepotHeadAndDetail(url,infoStr,preTotalPrice);
- return;
- }
- }
- });
-
- //打印单据
- $("#printDepotHeadShow").off("click").on("click",function(){
- var tableString = $("#depotHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event){
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="State"||obj.id=="Number"))
- {
- $("#saveDepotHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber"||obj.id=="searchMaterial"))
- {
- $("#searchBtn").click();
- }
- });
-
- //优惠率输入框事件
- $("#Discount").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountNum = $(this).val();
- var discountMoney = (discountNum/100*totalPrice).toFixed(2);
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#DiscountMoney").val(discountMoney); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //优惠金额输入框事件
- $("#DiscountMoney").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountMoney = $(this).val();
- var discount = (discountMoney/totalPrice).toFixed(2)*100;
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#Discount").val(discount); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //付款、收款输入框事件
- $("#ChangeAmount").off("keyup").on("keyup",function(){
- var discountLastMoney = $("#DiscountLastMoney").val();
- var changeAmount = $(this).val();
- var debtMoney = (discountLastMoney - changeAmount).toFixed(2);
- $("#Debt").val(debtMoney); //本次欠款
- });
-
- //多账户结算窗口弹出事件
- function depotHeadAccountDlgFun(){
- $('#depotHeadAccountDlg').dialog('open').dialog('setTitle','
多账户结算');
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").remove(); //先移除输入栏目
- $("#accountMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#depotHeadAccountDlg .tabs-tmp .account-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#depotHeadAccountDlg .tabs-tmp tbody").html();
- var accountDlgHead = $("#depotHeadAccountDlg .account-head-tmp");
- accountDlgHead.after(contentTmp);
- }
-
- //获取账户信息
- function accountDlgFun() {
- var options = "";
- if(accountList !=null){
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- }
- $(".account-id-dlg").empty().append("").append(options);
- }
- }
- accountDlgFun(); //获取账户信息
- $("#depotHeadAccountDlg .tabs-tmp").hide(); //隐藏模板
-
- //账户金额输入框事件-多账户
- $("#depotHeadAccountDlg .account-dlg .account-money-dlg").off("keyup").on("keyup",function(){
- var totalAccoutNum = 0;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var eachAccountMoney = $(this).find(".account-money-dlg").val()-0;
- totalAccoutNum += eachAccountMoney;
- });
- $("#accountMoneyTotalDlg").text(totalAccoutNum);
- });
-
- //结算多账户列表的切换事件
- $("#depotHeadAccountDlg .account-dlg .account-id-dlg").off("change").on("change",function(){
- var selectAccount = $(this).children('option:selected').text();
- if(selectAccount === ""){
- var thisMoneyDom = $(this).closest(".account-content-tmp").find(".account-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text() - 0;
- $("#accountMoneyTotalDlg").text(accountMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //账户为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveDepotHeadAccountDlg").off("click").on("click", function(){
- //完成多账户的json数据存储
- var accountArr = []; //账户id数组
- var accountMoneyArr = []; //账户金额数组
- var errorIndex = -1;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var thisAccId = $(this).find(".account-id-dlg").val();
- var thisAccMoney = $(this).find(".account-money-dlg").val();
- if(!thisAccId && thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && !thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && thisAccMoney) {
- accountArr.push(thisAccId);
- accountMoneyArr.push(thisAccMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var discountLastMoneyNum =$("#DiscountLastMoney").val()-0; //优惠后金额
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text()-0; //本次付款或者收款
- if(accountMoneyTotal===0){
- $.messager.alert('错误提示',"请填写金额后保存",'warning');
- return;
- }
- if(accountArr.length && accountMoneyArr.length) {
- $("#AccountId").attr("data-accountArr",JSON.stringify(accountArr)).attr("data-accountMoneyArr",JSON.stringify(accountMoneyArr)); //json数据存储
- }
- $("#ChangeAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
- $("#Debt").val((discountLastMoneyNum-accountMoneyTotal).toFixed(2)); //本次欠款
- $("#depotHeadAccountDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#AccountId").attr("data-accountArr")){
- $("#depotHeadAccountDlg").dialog('close');
- }
- else {
- $("#depotHeadAccountDlg").dialog('close');
- $("#AccountId").val("").removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- }
- //多账户-取消按钮
- $("#cancelDepotHeadAccountDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //多账户-右上角的关闭按钮
- $("#depotHeadAccountDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
- }
- //点击多账户,弹出输入框
- $("#AccountId").off("change").on("change",function(){
- var selectText = $(this).children('option:selected').text();
- if(selectText === "多账户"){
- $("#ChangeAmount").prop("readonly","readonly");
- depotHeadAccountDlgFun();
- $(".many-account-ico").show(); //显示多账户小图标
- }
- else{
- $(this).removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- });
-
- //结算账户-多账户小图标-点击事件
- $(".many-account-ico").off("click").on("click",function(){
- depotHeadAccountDlgFun();
- //给弹窗赋值-多账户数据
- var accountArr = $("#AccountId").attr("data-accountArr");
- accountArr = JSON.parse(accountArr);
- var accountMoneyArr = $("#AccountId").attr("data-accountMoneyArr");
- accountMoneyArr = JSON.parse(accountMoneyArr);
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".account-id-dlg").val(accountArr[index]);
- $(this).find(".account-money-dlg").val(accountMoneyArr[index]);
- });
- $("#accountMoneyTotalDlg").text($("#ChangeAmount").val());
- });
-
- //点击采购费用、销售费用的事件
- $(".other-money-ico").off("click").on("click",function(){
- $('#otherMoneyDlg').dialog('open').dialog('setTitle','
'+ listSubType +'费用');
- $("#otherMoneyDlg .money-dlg .money-content-tmp").remove(); //先移除输入栏目
- $("#otherMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#otherMoneyDlg .tabs-tmp .money-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#otherMoneyDlg .tabs-tmp tbody").html();
- var moneyDlgHead = $("#otherMoneyDlg .money-head-tmp");
- moneyDlgHead.after(contentTmp);
- }
-
- //获取支出项目信息
- function moneyDlgFun() {
- var options = "";
- if(outItemList !=null){
- for(var i = 0 ;i < outItemList.length;i++) {
- var money = outItemList[i];
- options += '';
- }
- $(".money-id-dlg").empty().append("").append(options);
- }
- }
- moneyDlgFun(); //获取支出项目信息
- $("#otherMoneyDlg .tabs-tmp").hide(); //隐藏模板
-
- //支出项目的金额输入框事件
- $("#otherMoneyDlg .money-dlg .other-money-dlg").off("keyup").on("keyup",function(){
- var totalMoneyNum = 0;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var eachOtherMoney = $(this).find(".other-money-dlg").val()-0;
- totalMoneyNum += eachOtherMoney;
- });
- $("#otherMoneyTotalDlg").text(totalMoneyNum);
- });
-
- //支出项目列表的切换事件
- $("#otherMoneyDlg .money-dlg .money-id-dlg").off("change").on("change",function(){
- var selectItem = $(this).children('option:selected').text();
- if(selectItem === ""){
- var thisMoneyDom = $(this).closest(".money-content-tmp").find(".other-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text() - 0;
- $("#otherMoneyTotalDlg").text(otherMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //支出项目为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveOtherMoneyDlg").off("click").on("click", function(){
- //完成支出项目的json数据存储
- var itemArr = []; //支出项目id数组
- var itemMoneyArr = []; //支出项目金额数组
- var errorIndex = -1;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var thisId = $(this).find(".money-id-dlg").val();
- var thisMoney = $(this).find(".other-money-dlg").val();
- if(!thisId && thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && !thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && thisMoney) {
- itemArr.push(thisId);
- itemMoneyArr.push(thisMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text()-0; //合计金额
- if(otherMoneyTotal === 0){ //0的时候清空缓存数据
- $("#OtherMoney").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr");
- }
- if(itemArr.length && itemMoneyArr.length) {
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
- $("#OtherMoney").val(otherMoneyTotal); //给采购费用、销售费用赋值
- $("#otherMoneyDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#OtherMoney").attr("data-itemArr")){
- $("#otherMoneyDlg").dialog('close');
- }
- else {
- $("#otherMoneyDlg").dialog('close');
- $("#OtherMoney").val("").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr"); //将下拉置空并把缓存参数清空
- }
- }
- //费用-取消按钮
- $("#cancelOtherMoneyDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //费用-右上角的关闭按钮
- $("#otherMoneyDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
-
- //给弹窗赋值-采购费用、销售费用数据
- var itemArr = $("#OtherMoney").attr("data-itemArr");
- itemArr = JSON.parse(itemArr);
- var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr");
- itemMoneyArr = JSON.parse(itemMoneyArr);
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".money-id-dlg").val(itemArr[index]);
- if(itemMoneyArr[index]!="undefined"){
- $(this).find(".other-money-dlg").val(itemMoneyArr[index]);
- }
- });
- $("#otherMoneyTotalDlg").text($("#OtherMoney").val());
- });
- var supplierType = "供应商";
- //检查单位名称是否存在 ++ 重名无法提示问题需要跟进
- function checkSupplierName() {
- var supplierName = $.trim($("#supplier").val());
- var orgSupplier = "";
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(supplierName.length > 0 &&( orgSupplier.length ==0 || supplierName != orgSupplier))
- {
- $.ajax({
- type:"get",
- url: "/supplier/checkIsNameExist",
- dataType: "json",
- async : false,
- data: ({
- id : 0,
- name : supplierName
- }),
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data && res.data.status) {
- flag = res.data.status;
- if (flag) {
- $.messager.alert('提示', '单位名称已经存在', 'info');
- return;
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('提示','检查单位名称是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
-
- //保存供应商信息
- $("#saveSupplier").off("click").on("click",function() {
- if(validateForm("supplierFM")) {
- return;
- }
- if(checkSupplierName()){
- return;
- }
- var reg = /^([0-9])+$/;
- var phonenum = $.trim($("#phonenum").val());
- if(phonenum.length>0 && !reg.test(phonenum))
- {
- $.messager.alert('提示','电话号码只能是数字','info');
- $("#phonenum").val("").focus();
- return;
- }
- var beginNeedGet = $.trim($("#BeginNeedGet").val());
- var beginNeedPay = $.trim($("#BeginNeedPay").val());
- if(beginNeedGet && beginNeedPay) {
- $.messager.alert('提示','期初应收和期初应付不能同时输入','info');
- return;
- }
- var url = '/supplier/add';
- var supObj = $("#supplierFM").serializeObject();
- supObj.type = supplierType;
- supObj.enabled = 1;
- $.ajax({
- url: url,
- type:"post",
- dataType: "json",
- data:{
- info: JSON.stringify(supObj)
- },
- success: function(res) {
- if (res) {
- $('#supplierDlg').dialog('close');
- initSupplier(); //刷新供应商
- }
- }
- });
- });
-}
-
-function showDepotHeadDetails(pageNo,pageSize){
- var materialParam = $.trim($("#searchMaterial").val());
- var beginTime = $.trim($("#searchBeginTime").val());
- var endTime = $.trim($("#searchEndTime").val());
- if(beginTime) {
- beginTime = beginTime + ' 00:00:00';
- }
- if(endTime) {
- endTime = endTime + ' 23:59:59';
- }
- $.ajax({
- type: "get",
- url: "/depotHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- subType: listSubType,
- state: $.trim($("#searchState").val()),
- number: $.trim($("#searchNumber").val()),
- beginTime: beginTime,
- endTime: endTime,
- materialParam: materialParam,
- depotIds: depotString
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- return;
- }
- });
-}
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#depotHeadFM .datagrid-body");
- var footer =$("#depotHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
- //点击商品下拉框,自动加载数量、单价、金额
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //点击库存文本框,字段计算库存
- body.find("[field='Stock']").find(input).off("click").on("click",function(){
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- var monthTime = getNowFormatMonth();
- if(depotId && mId){
- var ratio = body.find("[field='Unit']").find(input).attr("data-ratio");
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //在新增的时候,这个ratio有值;在编辑的时候,这个ratio为undefined
- var type = "click"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratio, type);
- }
- else{
- body.find("[field='Stock']").find(input).val(0).attr("data-stock",0); //加载库存数据
- }
- });
- //修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计
- body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber =$(this).val()-0; //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
-
- });
- //修改单价,自动计算金额和合计
- body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice =$(this).val()-0; //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击单价,自动提示参考价格列表
- body.find("[field='UnitPrice']").find(input).off("click").on("click",function(){
- var self = this;
- var mValue = body.find("[field='MaterialId'] .combo-value").attr("value"); //获取选中的商品id
- if(!mValue) {
- return;
- }
- else {
- return;
- }
- });
- //修改含税单价,自动计算单价、金额、税额、价税合计和合计
- body.find("[field='TaxUnitPrice']").find(input).off("keyup").on("keyup",function(){
- var TaxUnitPrice =$(this).val()-0; //含税单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var UnitPrice = TaxUnitPrice/(1+taxRate/100); //计算单价
- body.find("[field='UnitPrice']").find(input).val((UnitPrice).toFixed(2)); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改金额,自动计算单价、税额、价税合计和合计
- body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var AllPrice =$(this).val()-0; //金额
- var UnitPrice = (AllPrice/OperNumber).toFixed(2);
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税率,自动计算含税单价、税额、价税合计和合计
- body.find("[field='TaxRate']").find(input).off("keyup").on("keyup",function(){
- var taxRate =$(this).val()-0; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税额,自动计算税率、含税单价、价税合计和合计
- body.find("[field='TaxMoney']").find(input).off("keyup").on("keyup",function(){
- var taxMoney =$(this).val()-0; //税额
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = taxMoney/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改价税合计,自动计算税率、含税单价、税额和合计
- body.find("[field='TaxLastMoney']").find(input).off("keyup").on("keyup",function(){
- var taxLastMoney =$(this).val()-0; //价税合计
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = (taxLastMoney-AllPrice)/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
-
- //加载税率
- if(thisTaxRate) {
- body.find("[field='TaxRate']").find(input).val(thisTaxRate);
- }
- else {
- body.find("[field='TaxRate']").find(input).val(0); //默认为0
- }
-
- //在商品类型加载 组装件、普通子件
- var mType = body.find("[field='MType']");
- var rowListLength = mType.find(input).closest(".datagrid-row").attr("datagrid-row-index");
- var mTypeValue = "组合件";
- if(rowListLength > 0){
- mTypeValue = "普通子件";
- }
- },500);
-}
-
-//结束编辑
-function endEditing() {
- if (editIndex == undefined) { return true }
- if ($('#materialData').datagrid('validateRow', editIndex)) {
- //仓库信息
- var edDepot = $('#materialData').datagrid('getEditor', {index:editIndex,field:'DepotId'});
- var DepotName = $(edDepot.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName;
- //商品信息
- var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'});
- var MaterialName = $(edMaterial.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName;
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#materialData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append(){
- if (endEditing()) {
- $('#materialData').datagrid('appendRow', {DepotId:defDepotId});
- editIndex = $('#materialData').datagrid('getRows').length - 1;
- $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function batchDel(){
- /**
- * 重写一下删除的逻辑
- * 获取所有选中行,直接从列表中移除
- * 点击保存时,将需要后台删除的数据提交到服务器
- * **/
- /**
- * create by: qiankunpingtai
- * create time: 2019/3/20 16:26
- * description:
- * 这个地方比较坑的,花了一个多小时才搞明白为什么
- * 1、删除之前必须先调用endEditing结束编辑
- * 2、如果只是调用endEditing结束编辑那么正在编辑行的被选中状态会被去掉
- * 所以要在调用endEditing先获取选中的行
- */
- //如果编辑的行一开始是选中状态,结束编辑后仍然是选中状态
- var row = $('#materialData').datagrid('getChecked');
- if (endEditing()) {
- if (row.length == 0) {
- $.messager.alert('删除提示', '没有记录被选中!', 'info');
- return;
- }
- if (row.length > 0) {
- $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条单据信息吗?', function (r) {
- if (r) {
- for (var i = 0; i < row.length; i++) {
- $('#materialData').datagrid('deleteRow', $('#materialData').datagrid("getRowIndex", row[i]));
- }
- }
- });
- }
- }
-}
-function removeit(){
- if (editIndex == undefined) { return }
- $('#materialData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#materialData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData(type) {
- var change = $('#materialData').datagrid('getChanges').length;
- if(type =="add" && !change) {
- $.messager.alert('提示','请输入明细信息!','warning');
- return false;
- }
- var row = $('#materialData').datagrid('getRows');
- if(!row.length){
- $.messager.alert('提示',"请输入明细信息!",'info');
- return false;
- }
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if (row[i].DepotId == "" || row[i].MaterialId == "" || row[i].OperNumber == "" || row[i].UnitPrice === "" || row[i].AllPrice === "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-
-
-/**
- * 新增单据主表及单据子表
- * */
-function addDepotHeadAndDetail(url,infoStr){
- var inserted = null;
- if(pageType === "skip") {
- inserted = $("#materialData").datagrid('getChanges', "updated");
- } else {
- inserted = $("#materialData").datagrid('getChanges', "inserted");
- }
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated)
- }),
- success: function (tipInfo){
-
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
-
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
-
-
- });
-}
-/**
- * 修改单据主表及单据子表
- * */
-function updateDepotHeadAndDetail(url,infoStr,preTotalPrice){
- var inserted = $("#materialData").datagrid('getChanges', "inserted");
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- id:url.substring(url.lastIndexOf("?id=")+4,url.length),
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- preTotalPrice:preTotalPrice
- }),
- success: function (tipInfo){
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
- if (endEditing()) {
- $('#materialData').datagrid('acceptChanges');
- }
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-
-
-
diff --git a/erp_web/js/pages/materials/purchase_orders_list.js b/erp_web/js/pages/materials/purchase_orders_list.js
deleted file mode 100644
index edfdfc36..00000000
--- a/erp_web/js/pages/materials/purchase_orders_list.js
+++ /dev/null
@@ -1,2438 +0,0 @@
-//初始化界面
-var defDepotId = null;
-var kid = sessionStorage.getItem("userId");
-var pageType = getUrlParam('t'); //获取页面类型传值
-var depotList = null;
-var depotID = null;
-var supplierList = null;
-var supplierID = null;
-var personList = null;
-var personID = null;
-var ProjectSearch=null;
-var userBusinessList=null;
-var userdepot=null;
-var url;
-var depotHeadID = 0;
-var preTotalPrice = 0; //前一次加载的金额
-var orgDepotHead = "";
-var editIndex = undefined;
-/**默认编号有意义吗,不如空着吧*/
-var orgDefaultId=''; //单位默认编号
-var orgDefaultList; //存储查询出来的会员列表
-var accountList; //账户列表
-var outItemList; //支出项目列表
-var thisTaxRate = 0; //当前税率,选择供应商或者客户的时候设置
-var oldNumber = ""; //编辑前的单据编号
-var oldId = 0; //编辑前的单据Id
-var otherColumns = true; //明细中的‘别名’列是否显示
-var btnEnableList = getBtnStr(); //获取按钮的权限
-var mPropertyList = ""; //商品属性列表
-var defaultAccountId = 0; //默认账户id
-//改变宽度和高度
-$("#searchPanel").panel({width:webW-2});
-$("#tablePanel").panel({width:webW-2});
-var listTitle = "采购订单列表"; //单据标题
-var depotString = "|"; //店铺id列表
-var listType ="其它";//入库 出库
-var listSubType = "采购订单";//采购 销售等
-var payTypeTitle = "隐藏"; //付款 收款
-var organUrl = "/supplier/findBySelect_sup"; //组织数据接口地址
-var amountNum ="CGDD";//单据编号开头字符
-$(function(){
- //初始化系统基础信息
- initSystemData_UB();
- initSelectInfo_UB();
- initSystemData_depot();
- initSelectInfo_depot();
- initSystemData_person();
- initSelectInfo_person();
- initSystemData_account();
- initSelectInfo_account();
- initSupplier(); //供应商
- initSalesman(); //销售人员
- initOutItemList(); //初始化支出项目
- initMProperty(); //初始化商品属性
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
-});
-//初始化系统基础信息
-function initSystemData_UB(){
- $.ajax({
- type:"get",
- url: "/userBusiness/getBasicData",
- data: ({
- KeyId:kid,
- Type:"UserDepot"
- }),
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if (res && res.code === 200) {
- userBusinessList = res.data.userBusinessList;
- }
- else {
- userBusinessList = null;
- }
- }
- });
-
-}
-//初始化页面选项卡
-function initSelectInfo_UB(){
-
- if(userBusinessList !=null)
- {
- if(userBusinessList.length>0)
- {
- //用户对应的仓库列表 [1][2][3]...
- userdepot =userBusinessList[0].value;
- }
- }
-}
-
-
-//初始化系统基础信息
-function initSystemData_depot(){
- $.ajax({
- type:"get",
- url: "/depot/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200){
- depotList = res.data;
- } else {
- $.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error');
- return;
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_depot(){
- var options = "";
-
- if(depotList !=null)
- {
- options = "";
- for(var i = 0 ;i < depotList.length;i++)
- {
- var depot = depotList[i];
-
- if(userdepot!=null)
- {
- if(userdepot.indexOf("["+depot.id+"]")!=-1)
- {
- if(depot.isDefault){
- defDepotId = depot.id;
- }
- options += '';
- depotString = depotString + depot.id + ",";
- }
- }
- if(depot.type === 1){
- depotString = depotString + depot.id + ",";
- }
- }
- depotString = depotString.substring(1, depotString.length-1);
- $("#ProjectId").empty().append(options);
- $("#AllocationProjectId").empty().append(options);
- $("#searchProjectId").empty().append('').append(options);
- }
-}
-
-//初始化供应商、客户、散户信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onLoadSuccess: function(res) {
- var data = $(this).combobox('getData');
- for(var i = 0; i<= data.length; i++){
- if(data && data[i] && data[i].supplier === "非会员"){
- orgDefaultId = data[i].id;
- }
- }
- },
- onSelect: function(rec){
- $.ajax({
- type:"get",
- url: "/supplier/findById",
- data: {
- supplierId: rec.id
- },
- dataType: "json",
- success: function (res){
- if(res && res.code === 200) {
- if(res.data && res.data[0]){
- thisTaxRate = res.data[0].taxRate; //设置当前的税率
- }
- }
- },
- error:function(){
-
- }
- });
- }
- });
-}
-
-//初始化销售人员
-function initSalesman(){
- $('#Salesman').combobox({
- url: "/person/getPersonByNumType?type=1",
- valueField:'id',
- textField:'name',
- multiple: true
- });
-}
-
-//初始化收入项目列表
-function initOutItemList(){
- $.ajax({
- type:"get",
- url: "/inOutItem/findBySelect?type=out",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res){
- if(res){
- outItemList = res;
- }
- },
- error:function(){
-
- }
- });
-}
-
-//初始化商品属性
-function initMProperty(){
- $.ajax({
- type: "get",
- url: "/materialProperty/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- name: ""
- }),
- currentPage: 1,
- pageSize: 100
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- var thisRows = res.data.page.rows;
- for (var i = 0; i < thisRows.length; i++) {
- if (thisRows[i].enabled) {
- mPropertyList += thisRows[i].nativename + ",";
- }
- }
- if (mPropertyList) {
- mPropertyList = mPropertyList.substring(0, mPropertyList.length - 1);
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化系统基础信息
-function initSystemData_person(){
- $.ajax({
- type:"get",
- url: "/person/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- personList = res.data.personList;
- }
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_person(){
- var options1 = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="仓管员")
- {
- options1 += '';
- }
- }
- $("#HandsPersonId").empty().append(options1);
- }
-}
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null){
- options = "";
- options += "";
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- if(account.isdefault) {
- defaultAccountId = account.id; //给账户赋值默认id
- }
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#depotHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- if(pageType === "skip") {
- var oldRowInfo = sessionStorage.getItem("rowInfo");
- editDepotHead(oldRowInfo); //自动弹出编辑框,带缓存数据
- }
- var hideType = undefined;
- var isHiddenStatus = true;
- if(payTypeTitle === "隐藏"){
- hideType = true; //隐藏当前列
- }
- var tableToolBar = [
- {
- id:'addDepotHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addDepotHead();
- }
- },
- {
- id:'deleteDepotHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteDepotHead();
- }
- }
- ];
- //如果允许的按钮列表中存在就显示,3-代表审核|反审核的权限
- if(btnEnableList && btnEnableList.indexOf(3)>-1){
- isHiddenStatus = false; //显示
- tableToolBar.push({
- id:'okDepotHead',
- text:'审核',
- iconCls:'icon-ok',
- handler:function() {
- setStatusFun();
- }
- },
- {
- id:'undoDepotHead',
- text:'反审核',
- iconCls:'icon-undo',
- handler:function() {
- setUnStatusFun();
- }
- });
- }
- else {
- isHiddenStatus = true; //隐藏
- }
- var isShowLastMoneyColumn = true; //是否显示优惠后金额和价税合计,true为隐藏,false为显示
- var isShowOrganNameColumn = false; //是否显示供应商、客户等信息,true为隐藏,false为显示
- var organNameTitle = "供应商名称"; //组织名称标题
- var opWidth = 120; //操作宽度
- var opTitle = "转采购入库"; //跳转按钮的标题
- $('#tableData').datagrid({
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: true,
- //交替出现背景
- striped : true,
- pageSize: 10,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:opWidth,
- formatter:function(value, rec,index) {
- var str = '';
- var orgId = rec.organid? rec.organid:0;
- str += '
';
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
- { title: '单据编号',field: 'number',width:135, formatter:function (value,rec) {
- if(rec.linknumber) {
- return value + "[转]";
- } else {
- return value;
- }
- }
- },
- { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
- if(value) {
- return value.replace(",",",");
- }
- }
- },
- { title: '单据日期',field: 'opertimeStr',width:130},
- { title: '操作员',field: 'operpersonname',width:60},
- { title: '金额合计',field: 'totalprice',width:60},
- { title: '含税合计',field: 'totaltaxlastmoney',hidden:isShowLastMoneyColumn,width:60,formatter:function(value,rec){
- return (rec.discountmoney + rec.discountlastmoney).toFixed(2);
- }
- },
- { title: '优惠后金额',field: 'discountlastmoney',hidden:isShowLastMoneyColumn,width:80},
- { title: payTypeTitle,field: 'changeamount',width:50,hidden:hideType},
- { title: '状态',field: 'status',hidden:isHiddenStatus, width:70,align:"center",formatter:function(value){
- if(value === "0") {
- return "未审核";
- } else if(value === "1") {
- return "已审核";
- } else if(value === "2") {
- return "已转采购";
- }
- }
- }
- ]],
- toolbar:tableToolBar,
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//查找库存的方法
-function findStockNumById(depotId, mId, monthTime, body, input, ratio, type){
- var thisRatio = 1; //比例
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (rec) {
- if(rec && rec.code === 200 && rec.data && rec.data[0]) {
- var loadRatio = 1; //在单位输入框上面加载比例字段
- if(rec.data[0].unit) { //如果存在计量单位信息
- loadRatio = 1;
- }
- else{
- var unitName = rec.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- thisRatio = unitName.substring(unitName.indexOf(":")+1).replace(")","");
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- unitSetInput = rec.data[0].firstinunit;
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = thisRatio;
- }
- }
- //查询库存
- $.ajax({
- type: "get",
- url: '/depotItem/findStockNumById',
- data:{
- projectId: depotId,
- materialId: mId
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if (res.data && res.data.page && res.data.page[0]) {
- var thisStock = res.data.page[0].thisSum;
- if (type == "select") { //选择下拉框的时候
- if (ratio != undefined && ratio != 1) {
- loadRatio = ratio;
- }
- }
- else if (type == "click") { //点击库存的时候
- if (ratio != undefined) {
- loadRatio = ratio;
- }
- }
- thisStock = (thisStock / loadRatio).toFixed(2);
- body.find("[field='Stock']").find(input).val(thisStock).attr("data-stock", res.data.page[0].thisSum); //加载库存数据
- }
- else {
- body.find("[field='Stock']").find(input).val(0).attr("data-stock", 0); //加载库存数据
- }
- body.find("[field='Stock']").find(input).prop("readonly", "readonly"); //设置库存数据为只读
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
- }
- },
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- }
- });
-}
-//优惠率、合计的统计方法
-function statisticsFun(body,UnitPrice,OperNumber,footer,taxRate){
- var TotalPrice = 0;
- var taxLastMoneyTotal = 0;
- //金额的合计
- body.find("[field='AllPrice']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + UnitPrice*OperNumber;
- footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); //金额的合计
- //价税合计的总计
- body.find("[field='TaxLastMoney']").each(function(){
- if($(this).find("div").text()!==""){
- taxLastMoneyTotal = taxLastMoneyTotal + (parseFloat($(this).find("div").text().toString())-0);
- }
- });
- taxLastMoneyTotal = taxLastMoneyTotal + (UnitPrice*OperNumber*(1+taxRate/100));
- footer.find("[field='TaxLastMoney']").find("div").text((taxLastMoneyTotal).toFixed(2)); //价税合计的页脚总计
- var discount = $("#Discount").val(); //优惠率
- var discountMoney = (taxLastMoneyTotal*discount/100).toFixed(2);
- $("#DiscountMoney").val(discountMoney);//优惠金额
- var discountLastMoney = (taxLastMoneyTotal*(1-discount/100)).toFixed(2)
- $("#DiscountLastMoney").val(discountLastMoney);//优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
-
-}
-//初始化表格数据-商品列表-编辑状态
-function initTableData_material(type,TotalPrice){
- var body,footer,input; //定义表格和文本框
- var ratio = 1; //比例-品名专用
- var ratioDepot = 1; //比例-仓库用
- var monthTime = getNowFormatMonth();
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var depotHeadName = ""; //仓库名称
- var depotUrl = ""; //仓库接口地址
- var depotTextField = ""; //仓库下拉名称
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var anotherDepotUrl = ""; //对方仓库接口地址
- var anotherDepotTextField = "";
- depotHeadName = "仓库名称";
- depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- depotTextField = "depotName";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialData').datagrid({
- height:245,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: '商品类型',field: 'MType',editor:'validatebox',hidden:isShowMaterialTypeColumn,width:80},
- { title: depotHeadName, field: 'DepotId', editor: 'validatebox', width: 90,
- formatter: function (value, row, index) {
- return row.DepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: depotTextField,
- method: 'get',
- url: depotUrl,
- onSelect:function(rec){
- var depotId = rec.id;
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- if(mId){
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratioDepot, type);
- }
- }
- }
- }
- },
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialId',width:230,
- formatter:function(value,row,index){
- return row.MaterialName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'MaterialName',
- method:'get',
- url: "/material/findBySelect",
- panelWidth: 300, //下拉框的宽度
- //全面模糊匹配,过滤字段
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onBeforeLoad: function(param){
- param.mpList = mPropertyList; //商品属性
- },
- onSelect:function(rec){
- if(rec) {
- var mId = rec.Id;
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (res) {
- if(res && res.code === 200 && res.data && res.data[0]) {
- var retailPrice = res.data[0].retailprice-0; //零售价格
- var presetPriceOne = res.data[0].presetpriceone-0; //预计采购价
- var presetPriceTwo = res.data[0].presetpricetwo-0; //批发价
- var firstInUnit = res.data[0].firstinunit; //首选入库单位
- var firstOutUnit = res.data[0].firstoutunit; //首选出库单位
- var basicPresetPriceOne = ""; //多单位-入库-基础价格
- var basicPresetPriceTwo = ""; //多单位-出库-基础价格
- var retailPriceOne = ""; //多单位-入库-零售价格
- var otherPresetPriceOne = ""; //多单位-入库-其他价格
- var otherPresetPriceTwo = ""; //多单位-出库-其他价格
- var retailPriceTwo = ""; //多单位-出库-零售价格
- var basicUnit = ""; //基础单位
- var otherUnit = ""; //其他单位
- if(!res.data[0].unit){
- var ps = res.data[0].pricestrategy;
- var psObj = JSON.parse(ps);
- basicPresetPriceOne = psObj[0].basic.PresetPriceOne-0;
- basicPresetPriceTwo = psObj[0].basic.PresetPriceTwo-0;
- retailPriceOne = psObj[0].basic.RetailPrice-0;
- otherPresetPriceOne = psObj[1].other.PresetPriceOne-0;
- otherPresetPriceTwo = psObj[1].other.PresetPriceTwo-0;
- retailPriceTwo = psObj[1].other.RetailPrice-0;
- basicUnit = psObj[0].basic.Unit;
- otherUnit = psObj[1].other.Unit;
- }
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- if(res.data[0].unit){ //如果存在计量单位信息
- ratio = 1; //重置比例为1
- body.find("[field='Unit']").find(input).val(res.data[0].unit); //设置-计量单位信息
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- body.find("[field='Unit']").find(input).off("click"); //移除点击事件
- body.find("[field='Unit']").find(input).attr("data-ratio",ratio); //修改比例缓存信息
- }
- else {
- var unitName = res.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- var loadRatio = 1; //在单位输入框上面加载比例字段
- unitSetInput = res.data[0].firstinunit; //给单位文本框赋值
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = ratio;
- }
- body.find("[field='Unit']").find(input).val(unitSetInput).attr("data-ratio", loadRatio); //设置-首选单位
-
- body.find("[field='Unit']").find(input).off("click").on("click",function(){
- if(basicUnit && otherUnit) {
- var self = this;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- " + basicUnit + "
";
- temp +="- " + otherUnit + "
";
- temp +="
";
- temp +="
";
- if($('.unit-list').length){
- $('.unit-list').remove(); //如果存在计量单位列表先移除
- }
- else {
- $(self).after(temp); //加载列表信息
- }
- //计量单位列表的单击事件
- $('.unit-list ul li').off("click").on("click",function(){
- var unit = $(this).text();
- var thisRatio = $(this).attr("data-ratio"); //获取比例
- $(self).val(unit).attr("data-ratio", thisRatio);
- $(self).keyup(); //模拟键盘操作
- $('.unit-list').remove(); //移除计量单位列表
- var stock = body.find("[field='Stock']").find(input).attr("data-stock"); //从缓存中取值
- var type = $(this).attr("data-type");
- var UnitPrice = 0;
- if(type === "basic"){
- UnitPrice = basicPresetPriceOne;
- body.find("[field='Stock']").find(input).val(stock); //修改库存
- }
- else if(type === "other"){
- UnitPrice = otherPresetPriceOne;
- body.find("[field='Stock']").find(input).val((stock/ratio).toFixed(2)); //修改库存
- }
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //获取数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击空白处移除计量单位列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.unit-list').remove(); //移除计量单位列表
- });
- }
- });
- }
- var detailPrice = 0; //明细列表-单价
- if(res.data[0].unit) { //如果存在计量单位信息
- detailPrice = presetPriceOne;
- }
- else {
- if (firstInUnit == basicUnit) {
- detailPrice = basicPresetPriceOne;
- }
- else if (firstInUnit == otherUnit) {
- detailPrice = otherPresetPriceOne;
- }
- }
- body.find("[field='OperNumber']").find(input).val(1); //数量初始化为1
- //单价和总价赋值
- if(!detailPrice) {
- detailPrice = 0;
- }
- body.find("[field='UnitPrice']").find(input).val(detailPrice);
- body.find("[field='AllPrice']").find(input).val(detailPrice);
- var taxRate = body.find("[field='TaxRate']").find(input).val()-0; //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((detailPrice*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,detailPrice,1,footer,taxRate);
-
- //查询库存信息
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- if(depotId) {
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, loadRatio, type);
- }
- }
- },
- error: function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- }
- });
- }
- }
- }
- }
- },
- { title: '库存',field: 'Stock',editor:'validatebox',width:70},
- { title: anotherDepotHeadName, field: 'AnotherDepotId',editor:'validatebox',hidden:isShowAnotherDepot,width:90,
- formatter: function (value, row, index) {
- return row.AnotherDepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: anotherDepotTextField,
- method: 'get',
- url: anotherDepotUrl
- }
- }
- },
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率(%)',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batchDel(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = 0;
- var TaxLastMoney = 0;
- var DiscountMoney = $("#DiscountMoney").val()-0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoney").val()-0; //优惠后金额
- if(type === "edit") {
- AllPrice = TotalPrice;
- TaxLastMoney = DiscountMoney + DiscountLastMoney;
- }
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": TaxLastMoney
- });
- data.footer = array;
- $("#materialData").datagrid('loadData',data);
- //如果是订单跳转到采购或销售
- if(pageType === "skip") {
- var skipList = $("#depotHeadFM .datagrid-body tr");
- //逐条自动点击每行数据
- skipList.each(function (i) {
- setTimeout(function () {
- skipList.eq(i).find("[field='Stock']").click();
- },(i+1)*1000);
- });
- }
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//初始化表格数据-商品列表-查看状态
-function initTableData_material_show(TotalPrice){
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var depotHeadName = ""; //仓库的列的标题
- depotHeadName = "仓库名称";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialDataShow').datagrid({
- height:245,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- onClickRow: onClickRow,
- columns:[[
- { title: '商品类型',field: 'MType',width:80, hidden:isShowMaterialTypeColumn},
- { title: depotHeadName,field: 'DepotName',editor:'validatebox',width:90},
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialName',width:230},
- { title: anotherDepotHeadName,field: 'AnotherDepotName',hidden:isShowAnotherDepot,width:90},
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validattebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = TotalPrice;
- var DiscountMoney = $("#DiscountMoneyShow").text() - 0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoneyShow").text() - 0; //优惠后金额
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": DiscountMoney + DiscountLastMoney
- });
- data.footer = array;
- $("#materialDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showDepotHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除单据信息
-function deleteDepotHead(depotHeadID, thisOrganId, totalPrice, status){
- if(status == "1" || status == "2") {
- $.messager.alert('删除提示','已审核和已转的单据不能删除!','warning');
- return;
- }
- $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
- if (r) {
- $.ajax({
- type:"post",
- // url: "/depotHead/" + depotHeadID + "/delete",
- url: "/depotHead/deleteDepotHeadAndDetail",
- dataType: "json",
- data:{
- id: depotHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-//订单转采购或销售
-function skipDepotHead(index, status){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- if(status == "0" || status == "2") {
- $.messager.alert('提示','未审核和已转的单据禁止操作!','warning');
- } else {
- sessionStorage.setItem("rowInfo", JSON.stringify(rowsdata)); //将单据信息存入缓存中
- parent.addTab("订单转采购", "../materials/purchase_in_list.html?t=skip", "");
- }
-}
-
-//批量删除单据信息
-function batDeleteDepotHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条单据信息吗?',function(r)
- {
- if (r) {
- var ids = "";
- for (var i = 0; i < row.length; i++) {
- if (i == row.length - 1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- if (ids) {
- //批量删除
- $.ajax({
- type: "post",
- // url: "/depotHead/batchDelete",
- url: "/depotHead/batchDeleteDepotHeadAndDetail",
- dataType: "json",
- async: false,
- data: ({
- ids: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除单据信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('删除提示','没有能删除的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量审核
-function setStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('审核确认','确定要审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: "1",
- depotHeadIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('审核提示', '审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('审核提示','审核信息异常,请稍后再试!','error');
- return;
- }
- });
- } else {
- $.messager.alert('审核提示','没有能审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量反审核
-function setUnStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('反审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('反审核确认','确定要反审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type: "post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async: false,
- data: ({
- status: "0",
- depotHeadIDs: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('反审核提示', '反审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('反审核提示', '反审核信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('反审核提示','没有能反审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//生成单据编号
-function buildNumber() {
- $.ajax({
- type: "get",
- url: "/depotHead/buildNumber",
- success:function(res){
- if(res && res.code === 200){
- var obj = res.data;
- var defaultNumber = obj.DefaultNumber;
- var newNumber = amountNum + defaultNumber;
- $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
- }
- },
- error:function(){
- $.messager.alert('提示','生成单据编号失败!','error');
- }
- });
-}
-
-//新增信息
-function addDepotHead(){
- $('#depotHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- buildNumber(); //生成单据编号
- //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为0
- $("#Discount").val(0);
- $("#DiscountMoney").val(0);
- $("#DiscountLastMoney").val(0);
- $("#ChangeAmount").val(0);
- $("#Debt").val(0);
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- var addTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgDepotHead = "";
- depotHeadID = 0;
- initTableData_material("add"); //商品列表
- reject(); //撤销下、刷新商品列表
- $("#addOrgan").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加供应商信息');
- $('#supplierFM').form('clear');
- });
-
- $("#addMember").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加会员信息');
- $('#supplierFM').form('clear');
- });
- $("#addCustomer").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加客户信息');
- $('#supplierFM').form('clear');
- });
- url = '/depotHead/addDepotHeadAndDetail';
-}
-
-//编辑信息
-function editDepotHead(index, status){
- if(status == "1" || status == "2") {
- $.messager.alert('编辑提示','已审核和已转的单据不能编辑!','warning');
- return;
- }
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata ='';
- if(Number(index).toString()=='NaN'){
- rowsdata=$.parseJSON(index);
- }else{
- rowsdata=$("#tableData").datagrid("getRows")[index];
- }
- $("#ProjectId").focus().val(rowsdata.projectid);
- var ProjectId=rowsdata.projectid;
- if(ProjectId!='') {
- initSystemData_person(ProjectId);
- initSelectInfo_person();
- }
- var TotalPrice = rowsdata.totalprice; //合计金额
- if(pageType === "skip") { //从订单跳转过来
- buildNumber(); //生成单据编号
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- $("#LinkNumber").val(rowsdata.number); //关联订单号
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- $("#DiscountLastMoney").val(TotalPrice); //优惠后金额
- $("#ChangeAmount").val(TotalPrice).attr("data-changeamount", TotalPrice);
- } else {
- $("#Number").val(rowsdata.number).attr("data-defaultNumber",rowsdata.number);
- $("#OperTime").val(rowsdata.opertimeStr);
- $("#LinkNumber").val(rowsdata.linknumber==undefined?"":rowsdata.linknumber); //关联订单号
- $("#AccountId").val(rowsdata.accountid); //账户Id
- $("#DiscountLastMoney").val(rowsdata.discountlastmoney==undefined?"0.00":rowsdata.discountlastmoney); //优惠后金额
- $("#ChangeAmount").val(rowsdata.changeamount).attr("data-changeamount", rowsdata.changeamount);
- }
- $('#OrganId').combobox('setValue', rowsdata.organid==undefined?'':rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#Remark").val(rowsdata.remark);
- $("#Discount").val(rowsdata.discount==undefined?"0":rowsdata.discount);
- $("#DiscountMoney").val(rowsdata.discountmoney==undefined?"0.00":rowsdata.discountmoney);
- $("#Debt").val(Number((rowsdata.discountlastmoney==undefined?'0.00':rowsdata.discountlastmoney-rowsdata.changeamount)).toFixed(2));
- $("#AccountDay").val(rowsdata.accountday==undefined?"":rowsdata.accountday); //结算天数
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于扣预付款
- $("#AllocationProjectId").val(rowsdata.allocationprojectid);
- oldNumber = rowsdata.number; //记录编辑前的单据编号
- oldId = rowsdata.id; //记录单据Id
- var editTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- depotHeadID = rowsdata.id;
-
- //采购入库、销售出库的多账户加载
- if(rowsdata.accountidlist!=undefined && rowsdata.accountmoneylist!=undefined){
- $("#AccountId").val("many"); //下拉框选中多账户
- var accountArr = rowsdata.accountidlist.split(",");
- var accountMoneyArr = rowsdata.accountmoneylist.split(",");
- accountMoneyArr = changeListFmtPlus(accountMoneyArr) //将数组单个金额中的数值转为正数
- $("#AccountId").attr("data-accountArr", JSON.stringify(accountArr)).attr("data-accountMoneyArr", JSON.stringify(accountMoneyArr)); //json数据存储
- $(".many-account-ico").show(); //显示多账户的ico图标
- }
-
- //采购入库、销售出库的费用数据加载
- if(rowsdata.othermoneylist &&rowsdata.othermoneyitem){
- $("#OtherMoney").val(rowsdata.othermoney==undefined?"0":rowsdata.othermoney); //采购费用、销售费用
- var itemArr = rowsdata.othermoneylist.split(",");
- var itemMoneyArr = rowsdata.othermoneyitem.split(",");
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
-
- initTableData_material("edit",TotalPrice); //商品列表
- reject(); //撤销下、刷新商品列表
- if(pageType === "skip") {
- url = '/depotHead/addDepotHeadAndDetail'; //如果是从订单跳转过来,则此处为新增的接口
- //jshjshjsh
- $("#depotHeadFM .datagrid-body").find("[field='DepotId']").click();
- } else {
- url = '/depotHead/updateDepotHeadAndDetail?id=' + rowsdata.id; //更新接口
- }
-}
-
-//查看信息
-function showDepotHead(index){
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var manyAccountMoney = 0; //多账户合计-零售
- $("#ProjectIdShow").text(rowsdata.projectName);
- $("#NumberShow").text(rowsdata.number);
- $("#OperTimeShow").text(rowsdata.opertimeStr);
- $('#OrganIdShow').text(rowsdata.organName==undefined?'':rowsdata.organName);
- $("#HandsPersonIdShow").text(rowsdata.handsPersonName);
- if(rowsdata.accountName && rowsdata.accountName!=undefined){
- $("#AccountIdShow").text(rowsdata.accountName); //结算账户
- } else {
- var accountArr = (rowsdata.accountidlist==undefined?"":rowsdata.accountidlist).split(","); //账户id列表
- var accountMoneyArr =(rowsdata.accountmoneylist==undefined?"":rowsdata.accountmoneylist).split(","); //账户金额列表
- var accountIdShow = "";
- for(var j =0;j 查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- depotHeadID = rowsdata.id;
- initTableData_material_show(TotalPrice); //商品列表-查看状态
-}
-
-//绑定操作事件
-function bindEvent(){
- showDepotHeadDetails(1,initPageSize); //初始化时自动查询
- //搜索处理
- $("#searchBtn").off("click").on("click",function(){
- showDepotHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh',
- {
- pageNumber:1,
- pageSize:initPageSize
- });
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- //$("#searchProjectId").val("");
- $("#searchState").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //检查单据编号是否存在
- function checkDepotHeadNumber() {
- var thisNumber = $.trim($("#Number").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(thisNumber.length > 0 &&( oldNumber.length ==0 || thisNumber != oldNumber))
- {
- $.ajax({
- type:"get",
- url: "/depotHead/checkIsNumberExist",
- dataType: "json",
- async : false,
- data: ({
- DepotHeadID : oldId,
- Number : thisNumber
- }),
- success: function (tipInfo)
- {
- flag = tipInfo;
- if(tipInfo)
- {
- $.messager.alert('提示','抱歉,该单据编号已经存在','warning');
- return;
- }
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','检查单据编号是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
- //保存信息
- /**
- * 2019-01-25
- * 我对这个方法的实现结果存在严重怀疑,决定重构
- * 有如下疑点:
- * 1、保存完主表,返回结果后,再发起请求去操作子表,如何保证事务的一致性(业务数据一致性)
- * 2、保存完主表后,再通过selectmax的方式去获取主表主键id完全就是看人品的不可靠的思路
- * 修改计划:
- * 2019-01-25修改零售出库相关操作
- * 修改方式,重写url,将主从表操作合并
- *
- *
- * **/
- $("#saveDepotHead").off("click").on("click",function(){
- if(!$('#depotHeadFM').form('validate')){
- return;
- }
- else {
- //如果初始编号被修改了,就要判断单据编号是否存在
- if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
- //调用查询单据编号是否重名的方法
- if(checkDepotHeadNumber()){
- return;
- }
- }
- //输入框提示
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择供应商!','warning');
- return;
- }
- if (editIndex != undefined) {
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- //进行明细的校验
- if(depotHeadID ==0) {
- //新增模式下
- if (!CheckData("add")) {
- return;
- }
- }
- else {
- //编辑模式下
- if (!CheckData("edit")) {
- return;
- }
- }
- var OrganId = null, ProjectId = null,AllocationProjectId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val())-0;
- var TotalPrice = $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text();
- if($('#OrganId').length){
- OrganId = $('#OrganId').combobox('getValue');
- }
- var accountMoneyList = $("#AccountId").attr("data-accountmoneyarr"); //账户金额列表-多账户
- var accountMoneyArr;
- if(accountMoneyList) {
- accountMoneyList = accountMoneyList.replace("[","").replace("]","").toString();
- var reg=new RegExp("\"","g"); //创建正则RegExp对象
- accountMoneyList = accountMoneyList.replace(reg,""); //替换所有的双引号
- accountMoneyArr = accountMoneyList.split(","); //转为数组
- }
- //付款为负数
- ChangeAmount = 0 - ChangeAmount;
- TotalPrice = 0 - TotalPrice;
- if(accountMoneyArr) {
- accountMoneyArr = changeListFmtMinus(accountMoneyArr); //将数组单个金额中的数值转为负数
- }
- //零售时候,可以从会员预付款中扣款
- var thisPayType = "现付";
- var SalesmanStr = "";
- var getAccountID = $.trim($("#AccountId").val());
- if($("#AccountId").val() === "many"){ //多账户
- getAccountID = null;
- }
- var infoStr=JSON.stringify({
- Type: listType,
- SubType: listSubType,
- ProjectId: ProjectId,
- AllocationProjectId: AllocationProjectId,
- DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
- Number: $.trim($("#Number").val()),
- LinkNumber: $.trim($("#LinkNumber").val()),
- OperTime: $("#OperTime").val(),
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Salesman: SalesmanStr, //销售人员
- AccountId: getAccountID,
- ChangeAmount: ChangeAmount, //付款/收款
- TotalPrice: TotalPrice, //合计
- PayType: thisPayType, //现付/预付款
- Remark: $.trim($("#Remark").val()),
- AccountIdList: $("#AccountId").attr("data-accountarr"), //账户列表-多账户
- AccountMoneyList: accountMoneyArr ? JSON.stringify(accountMoneyArr) : "", //账户金额列表-多账户
- Discount: $.trim($("#Discount").val()),
- DiscountMoney: $.trim($("#DiscountMoney").val()),
- DiscountLastMoney: $.trim($("#DiscountLastMoney").val()),
- OtherMoney: $.trim($("#OtherMoney").val()), //采购费用、销售费用
- OtherMoneyList: $("#OtherMoney").attr("data-itemarr"), //支出项目列表-涉及费用
- OtherMoneyItem: $("#OtherMoney").attr("data-itemmoneyarr"), //支出项目金额列表-涉及费用
- AccountDay: $("#AccountDay").val() //结算天数
- });
- /**
- * 零售出库,单独操作
- * */
- if(url.indexOf("/depotHead/addDepotHeadAndDetail")>=0){
- addDepotHeadAndDetail(url,infoStr);
- return;
- }else if(url.indexOf("/depotHead/updateDepotHeadAndDetail")>=0){
- updateDepotHeadAndDetail(url,infoStr,preTotalPrice);
- return;
- }
- }
- });
-
- //打印单据
- $("#printDepotHeadShow").off("click").on("click",function(){
- var tableString = $("#depotHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event){
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="State"||obj.id=="Number"))
- {
- $("#saveDepotHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber"||obj.id=="searchMaterial"))
- {
- $("#searchBtn").click();
- }
- });
-
- //优惠率输入框事件
- $("#Discount").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountNum = $(this).val();
- var discountMoney = (discountNum/100*totalPrice).toFixed(2);
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#DiscountMoney").val(discountMoney); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //优惠金额输入框事件
- $("#DiscountMoney").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountMoney = $(this).val();
- var discount = (discountMoney/totalPrice).toFixed(2)*100;
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#Discount").val(discount); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //付款、收款输入框事件
- $("#ChangeAmount").off("keyup").on("keyup",function(){
- var discountLastMoney = $("#DiscountLastMoney").val();
- var changeAmount = $(this).val();
- var debtMoney = (discountLastMoney - changeAmount).toFixed(2);
- $("#Debt").val(debtMoney); //本次欠款
- });
-
- //多账户结算窗口弹出事件
- function depotHeadAccountDlgFun(){
- $('#depotHeadAccountDlg').dialog('open').dialog('setTitle','
多账户结算');
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").remove(); //先移除输入栏目
- $("#accountMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#depotHeadAccountDlg .tabs-tmp .account-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#depotHeadAccountDlg .tabs-tmp tbody").html();
- var accountDlgHead = $("#depotHeadAccountDlg .account-head-tmp");
- accountDlgHead.after(contentTmp);
- }
-
- //获取账户信息
- function accountDlgFun() {
- var options = "";
- if(accountList !=null){
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- }
- $(".account-id-dlg").empty().append("").append(options);
- }
- }
- accountDlgFun(); //获取账户信息
- $("#depotHeadAccountDlg .tabs-tmp").hide(); //隐藏模板
-
- //账户金额输入框事件-多账户
- $("#depotHeadAccountDlg .account-dlg .account-money-dlg").off("keyup").on("keyup",function(){
- var totalAccoutNum = 0;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var eachAccountMoney = $(this).find(".account-money-dlg").val()-0;
- totalAccoutNum += eachAccountMoney;
- });
- $("#accountMoneyTotalDlg").text(totalAccoutNum);
- });
-
- //结算多账户列表的切换事件
- $("#depotHeadAccountDlg .account-dlg .account-id-dlg").off("change").on("change",function(){
- var selectAccount = $(this).children('option:selected').text();
- if(selectAccount === ""){
- var thisMoneyDom = $(this).closest(".account-content-tmp").find(".account-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text() - 0;
- $("#accountMoneyTotalDlg").text(accountMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //账户为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveDepotHeadAccountDlg").off("click").on("click", function(){
- //完成多账户的json数据存储
- var accountArr = []; //账户id数组
- var accountMoneyArr = []; //账户金额数组
- var errorIndex = -1;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var thisAccId = $(this).find(".account-id-dlg").val();
- var thisAccMoney = $(this).find(".account-money-dlg").val();
- if(!thisAccId && thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && !thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && thisAccMoney) {
- accountArr.push(thisAccId);
- accountMoneyArr.push(thisAccMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var discountLastMoneyNum =$("#DiscountLastMoney").val()-0; //优惠后金额
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text()-0; //本次付款或者收款
- if(accountMoneyTotal===0){
- $.messager.alert('错误提示',"请填写金额后保存",'warning');
- return;
- }
- if(accountArr.length && accountMoneyArr.length) {
- $("#AccountId").attr("data-accountArr",JSON.stringify(accountArr)).attr("data-accountMoneyArr",JSON.stringify(accountMoneyArr)); //json数据存储
- }
- $("#ChangeAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
- $("#Debt").val((discountLastMoneyNum-accountMoneyTotal).toFixed(2)); //本次欠款
- $("#depotHeadAccountDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#AccountId").attr("data-accountArr")){
- $("#depotHeadAccountDlg").dialog('close');
- }
- else {
- $("#depotHeadAccountDlg").dialog('close');
- $("#AccountId").val("").removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- }
- //多账户-取消按钮
- $("#cancelDepotHeadAccountDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //多账户-右上角的关闭按钮
- $("#depotHeadAccountDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
- }
- //点击多账户,弹出输入框
- $("#AccountId").off("change").on("change",function(){
- var selectText = $(this).children('option:selected').text();
- if(selectText === "多账户"){
- $("#ChangeAmount").prop("readonly","readonly");
- depotHeadAccountDlgFun();
- $(".many-account-ico").show(); //显示多账户小图标
- }
- else{
- $(this).removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- });
-
- //结算账户-多账户小图标-点击事件
- $(".many-account-ico").off("click").on("click",function(){
- depotHeadAccountDlgFun();
- //给弹窗赋值-多账户数据
- var accountArr = $("#AccountId").attr("data-accountArr");
- accountArr = JSON.parse(accountArr);
- var accountMoneyArr = $("#AccountId").attr("data-accountMoneyArr");
- accountMoneyArr = JSON.parse(accountMoneyArr);
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".account-id-dlg").val(accountArr[index]);
- $(this).find(".account-money-dlg").val(accountMoneyArr[index]);
- });
- $("#accountMoneyTotalDlg").text($("#ChangeAmount").val());
- });
-
- //点击采购费用、销售费用的事件
- $(".other-money-ico").off("click").on("click",function(){
- $('#otherMoneyDlg').dialog('open').dialog('setTitle','
'+ listSubType +'费用');
- $("#otherMoneyDlg .money-dlg .money-content-tmp").remove(); //先移除输入栏目
- $("#otherMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#otherMoneyDlg .tabs-tmp .money-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#otherMoneyDlg .tabs-tmp tbody").html();
- var moneyDlgHead = $("#otherMoneyDlg .money-head-tmp");
- moneyDlgHead.after(contentTmp);
- }
-
- //获取支出项目信息
- function moneyDlgFun() {
- var options = "";
- if(outItemList !=null){
- for(var i = 0 ;i < outItemList.length;i++) {
- var money = outItemList[i];
- options += '';
- }
- $(".money-id-dlg").empty().append("").append(options);
- }
- }
- moneyDlgFun(); //获取支出项目信息
- $("#otherMoneyDlg .tabs-tmp").hide(); //隐藏模板
-
- //支出项目的金额输入框事件
- $("#otherMoneyDlg .money-dlg .other-money-dlg").off("keyup").on("keyup",function(){
- var totalMoneyNum = 0;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var eachOtherMoney = $(this).find(".other-money-dlg").val()-0;
- totalMoneyNum += eachOtherMoney;
- });
- $("#otherMoneyTotalDlg").text(totalMoneyNum);
- });
-
- //支出项目列表的切换事件
- $("#otherMoneyDlg .money-dlg .money-id-dlg").off("change").on("change",function(){
- var selectItem = $(this).children('option:selected').text();
- if(selectItem === ""){
- var thisMoneyDom = $(this).closest(".money-content-tmp").find(".other-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text() - 0;
- $("#otherMoneyTotalDlg").text(otherMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //支出项目为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveOtherMoneyDlg").off("click").on("click", function(){
- //完成支出项目的json数据存储
- var itemArr = []; //支出项目id数组
- var itemMoneyArr = []; //支出项目金额数组
- var errorIndex = -1;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var thisId = $(this).find(".money-id-dlg").val();
- var thisMoney = $(this).find(".other-money-dlg").val();
- if(!thisId && thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && !thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && thisMoney) {
- itemArr.push(thisId);
- itemMoneyArr.push(thisMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text()-0; //合计金额
- if(otherMoneyTotal === 0){ //0的时候清空缓存数据
- $("#OtherMoney").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr");
- }
- if(itemArr.length && itemMoneyArr.length) {
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
- $("#OtherMoney").val(otherMoneyTotal); //给采购费用、销售费用赋值
- $("#otherMoneyDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#OtherMoney").attr("data-itemArr")){
- $("#otherMoneyDlg").dialog('close');
- }
- else {
- $("#otherMoneyDlg").dialog('close');
- $("#OtherMoney").val("").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr"); //将下拉置空并把缓存参数清空
- }
- }
- //费用-取消按钮
- $("#cancelOtherMoneyDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //费用-右上角的关闭按钮
- $("#otherMoneyDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
-
- //给弹窗赋值-采购费用、销售费用数据
- var itemArr = $("#OtherMoney").attr("data-itemArr");
- itemArr = JSON.parse(itemArr);
- var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr");
- itemMoneyArr = JSON.parse(itemMoneyArr);
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".money-id-dlg").val(itemArr[index]);
- if(itemMoneyArr[index]!="undefined"){
- $(this).find(".other-money-dlg").val(itemMoneyArr[index]);
- }
- });
- $("#otherMoneyTotalDlg").text($("#OtherMoney").val());
- });
-
- var supplierType = "供应商";
- //检查单位名称是否存在 ++ 重名无法提示问题需要跟进
- function checkSupplierName() {
- var supplierName = $.trim($("#supplier").val());
- var orgSupplier = "";
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(supplierName.length > 0 &&( orgSupplier.length ==0 || supplierName != orgSupplier))
- {
- $.ajax({
- type:"get",
- url: "/supplier/checkIsNameExist",
- dataType: "json",
- async : false,
- data: ({
- id : 0,
- name : supplierName
- }),
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data && res.data.status) {
- flag = res.data.status;
- if (flag) {
- $.messager.alert('提示', '单位名称已经存在', 'info');
- return;
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('提示','检查单位名称是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
-
- //保存供应商信息
- $("#saveSupplier").off("click").on("click",function() {
- if(validateForm("supplierFM")) {
- return;
- }
- if(checkSupplierName()){
- return;
- }
- var reg = /^([0-9])+$/;
- var phonenum = $.trim($("#phonenum").val());
- if(phonenum.length>0 && !reg.test(phonenum))
- {
- $.messager.alert('提示','电话号码只能是数字','info');
- $("#phonenum").val("").focus();
- return;
- }
- var beginNeedGet = $.trim($("#BeginNeedGet").val());
- var beginNeedPay = $.trim($("#BeginNeedPay").val());
- if(beginNeedGet && beginNeedPay) {
- $.messager.alert('提示','期初应收和期初应付不能同时输入','info');
- return;
- }
- var url = '/supplier/add';
- var supObj = $("#supplierFM").serializeObject();
- supObj.type = supplierType;
- supObj.enabled = 1;
- $.ajax({
- url: url,
- type:"post",
- dataType: "json",
- data:{
- info: JSON.stringify(supObj)
- },
- success: function(res) {
- if (res) {
- $('#supplierDlg').dialog('close');
- initSupplier(); //刷新供应商
- }
- }
- });
- });
-}
-
-function showDepotHeadDetails(pageNo,pageSize){
- var materialParam = $.trim($("#searchMaterial").val());
- var beginTime = $.trim($("#searchBeginTime").val());
- var endTime = $.trim($("#searchEndTime").val());
- if(beginTime) {
- beginTime = beginTime + ' 00:00:00';
- }
- if(endTime) {
- endTime = endTime + ' 23:59:59';
- }
- $.ajax({
- type: "get",
- url: "/depotHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- subType: listSubType,
- state: $.trim($("#searchState").val()),
- number: $.trim($("#searchNumber").val()),
- beginTime: beginTime,
- endTime: endTime,
- materialParam: materialParam,
- depotIds: depotString
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#depotHeadFM .datagrid-body");
- var footer =$("#depotHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
- //点击商品下拉框,自动加载数量、单价、金额
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //点击库存文本框,字段计算库存
- body.find("[field='Stock']").find(input).off("click").on("click",function(){
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- var monthTime = getNowFormatMonth();
- if(depotId && mId){
- var ratio = body.find("[field='Unit']").find(input).attr("data-ratio");
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //在新增的时候,这个ratio有值;在编辑的时候,这个ratio为undefined
- var type = "click"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratio, type);
- }
- else{
- body.find("[field='Stock']").find(input).val(0).attr("data-stock",0); //加载库存数据
- }
- });
- //修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计
- body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber =$(this).val()-0; //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
-
- });
- //修改单价,自动计算金额和合计
- body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice =$(this).val()-0; //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击单价,自动提示参考价格列表
- body.find("[field='UnitPrice']").find(input).off("click").on("click",function(){
- var self = this;
- var mValue = body.find("[field='MaterialId'] .combo-value").attr("value"); //获取选中的商品id
- if(!mValue) {
- return;
- }
- else {
- return;
- }
- });
- //修改含税单价,自动计算单价、金额、税额、价税合计和合计
- body.find("[field='TaxUnitPrice']").find(input).off("keyup").on("keyup",function(){
- var TaxUnitPrice =$(this).val()-0; //含税单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var UnitPrice = TaxUnitPrice/(1+taxRate/100); //计算单价
- body.find("[field='UnitPrice']").find(input).val((UnitPrice).toFixed(2)); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改金额,自动计算单价、税额、价税合计和合计
- body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var AllPrice =$(this).val()-0; //金额
- var UnitPrice = (AllPrice/OperNumber).toFixed(2);
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税率,自动计算含税单价、税额、价税合计和合计
- body.find("[field='TaxRate']").find(input).off("keyup").on("keyup",function(){
- var taxRate =$(this).val()-0; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税额,自动计算税率、含税单价、价税合计和合计
- body.find("[field='TaxMoney']").find(input).off("keyup").on("keyup",function(){
- var taxMoney =$(this).val()-0; //税额
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = taxMoney/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改价税合计,自动计算税率、含税单价、税额和合计
- body.find("[field='TaxLastMoney']").find(input).off("keyup").on("keyup",function(){
- var taxLastMoney =$(this).val()-0; //价税合计
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = (taxLastMoney-AllPrice)/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
-
- //加载税率
- if(thisTaxRate) {
- body.find("[field='TaxRate']").find(input).val(thisTaxRate);
- }
- else {
- body.find("[field='TaxRate']").find(input).val(0); //默认为0
- }
-
- //在商品类型加载 组装件、普通子件
- var mType = body.find("[field='MType']");
- var rowListLength = mType.find(input).closest(".datagrid-row").attr("datagrid-row-index");
- var mTypeValue = "组合件";
- if(rowListLength > 0){
- mTypeValue = "普通子件";
- }
- },500);
-}
-
-//结束编辑
-function endEditing() {
- if (editIndex == undefined) { return true }
- if ($('#materialData').datagrid('validateRow', editIndex)) {
- //仓库信息
- var edDepot = $('#materialData').datagrid('getEditor', {index:editIndex,field:'DepotId'});
- var DepotName = $(edDepot.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName;
- //商品信息
- var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'});
- var MaterialName = $(edMaterial.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName;
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#materialData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append(){
- if (endEditing()) {
- $('#materialData').datagrid('appendRow', {DepotId:defDepotId});
- editIndex = $('#materialData').datagrid('getRows').length - 1;
- $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function batchDel(){
- /**
- * 重写一下删除的逻辑
- * 获取所有选中行,直接从列表中移除
- * 点击保存时,将需要后台删除的数据提交到服务器
- * **/
- /**
- * create by: qiankunpingtai
- * create time: 2019/3/20 16:26
- * description:
- * 这个地方比较坑的,花了一个多小时才搞明白为什么
- * 1、删除之前必须先调用endEditing结束编辑
- * 2、如果只是调用endEditing结束编辑那么正在编辑行的被选中状态会被去掉
- * 所以要在调用endEditing先获取选中的行
- */
- //如果编辑的行一开始是选中状态,结束编辑后仍然是选中状态
- var row = $('#materialData').datagrid('getChecked');
- if (endEditing()) {
- if (row.length == 0) {
- $.messager.alert('删除提示', '没有记录被选中!', 'info');
- return;
- }
- if (row.length > 0) {
- $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条单据信息吗?', function (r) {
- if (r) {
- for (var i = 0; i < row.length; i++) {
- $('#materialData').datagrid('deleteRow', $('#materialData').datagrid("getRowIndex", row[i]));
- }
- }
- });
- }
- }
-}
-function removeit(){
- if (editIndex == undefined) { return }
- $('#materialData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#materialData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData(type) {
- var change = $('#materialData').datagrid('getChanges').length;
- if(type =="add" && !change) {
- $.messager.alert('提示','请输入明细信息!','warning');
- return false;
- }
- var row = $('#materialData').datagrid('getRows');
- if(!row.length){
- $.messager.alert('提示',"请输入明细信息!",'info');
- return false;
- }
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if (row[i].DepotId == "" || row[i].MaterialId == "" || row[i].OperNumber == "" || row[i].UnitPrice === "" || row[i].AllPrice === "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-
-/**
- * 新增单据主表及单据子表
- * */
-function addDepotHeadAndDetail(url,infoStr){
- var inserted = null;
- if(pageType === "skip") {
- inserted = $("#materialData").datagrid('getChanges', "updated");
- } else {
- inserted = $("#materialData").datagrid('getChanges', "inserted");
- }
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated)
- }),
- success: function (tipInfo){
-
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
-
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
-
-
- });
-}
-/**
- * 修改单据主表及单据子表
- * */
-function updateDepotHeadAndDetail(url,infoStr,preTotalPrice){
- var inserted = $("#materialData").datagrid('getChanges', "inserted");
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- id:url.substring(url.lastIndexOf("?id=")+4,url.length),
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- preTotalPrice:preTotalPrice
- }),
- success: function (tipInfo){
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
- if (endEditing()) {
- $('#materialData').datagrid('acceptChanges');
- }
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-
-
-
diff --git a/erp_web/js/pages/materials/retail_back_list.js b/erp_web/js/pages/materials/retail_back_list.js
deleted file mode 100644
index f82a0bde..00000000
--- a/erp_web/js/pages/materials/retail_back_list.js
+++ /dev/null
@@ -1,2493 +0,0 @@
-//初始化界面
-var defDepotId = null;
-var kid = sessionStorage.getItem("userId");
-var pageType = getUrlParam('t'); //获取页面类型传值
-var depotList = null;
-var depotID = null;
-var supplierList = null;
-var supplierID = null;
-var personList = null;
-var personID = null;
-var ProjectSearch=null;
-var userBusinessList=null;
-var userdepot=null;
-var url;
-var depotHeadID = 0;
-var preTotalPrice = 0; //前一次加载的金额
-var orgDepotHead = "";
-var editIndex = undefined;
-/**默认编号有意义吗,不如空着吧*/
-var orgDefaultId=''; //单位默认编号
-var orgDefaultList; //存储查询出来的会员列表
-var accountList; //账户列表
-var outItemList; //支出项目列表
-var thisTaxRate = 0; //当前税率,选择供应商或者客户的时候设置
-var oldNumber = ""; //编辑前的单据编号
-var oldId = 0; //编辑前的单据Id
-var otherColumns = true; //明细中的‘别名’列是否显示
-var btnEnableList = getBtnStr(); //获取按钮的权限
-var mPropertyList = ""; //商品属性列表
-var defaultAccountId = 0; //默认账户id
-//改变宽度和高度
-$("#searchPanel").panel({width:webW-2});
-$("#tablePanel").panel({width:webW-2});
-var listTitle = "零售退货列表"; //单据标题
-var depotString = "|"; //店铺id列表
-var listType ="入库";//入库 出库
-var listSubType = "零售退货";//采购 销售等
-var payTypeTitle = "付款"; //付款 收款
-var organUrl ="/supplier/findBySelect_retail"; //组织数据接口地址
-var amountNum ="LSTH";//单据编号开头字符
-$(function(){
- //初始化系统基础信息
- initSystemData_UB();
- initSelectInfo_UB();
- initSystemData_depot();
- initSelectInfo_depot();
- initSystemData_person();
- initSelectInfo_person();
- initSystemData_account();
- initSelectInfo_account();
- initSupplier(); //供应商
- initSalesman(); //销售人员
- initOutItemList(); //初始化支出项目
- initMProperty(); //初始化商品属性
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
-});
-//初始化系统基础信息
-function initSystemData_UB(){
- $.ajax({
- type:"get",
- url: "/userBusiness/getBasicData",
- data: ({
- KeyId:kid,
- Type:"UserDepot"
- }),
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if (res && res.code === 200) {
- userBusinessList = res.data.userBusinessList;
- }
- else {
- userBusinessList = null;
- }
- }
- });
-
-}
-//初始化页面选项卡
-function initSelectInfo_UB(){
-
- if(userBusinessList !=null)
- {
- if(userBusinessList.length>0)
- {
- //用户对应的仓库列表 [1][2][3]...
- userdepot =userBusinessList[0].value;
- }
- }
-}
-
-
-//初始化系统基础信息
-function initSystemData_depot(){
- $.ajax({
- type:"get",
- url: "/depot/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200){
- depotList = res.data;
- } else {
- $.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error');
- return;
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_depot(){
- var options = "";
-
- if(depotList !=null)
- {
- options = "";
- for(var i = 0 ;i < depotList.length;i++)
- {
- var depot = depotList[i];
-
- if(userdepot!=null)
- {
- if(userdepot.indexOf("["+depot.id+"]")!=-1)
- {
- if(depot.isDefault){
- defDepotId = depot.id;
- }
- options += '';
- depotString = depotString + depot.id + ",";
- }
- }
- if(depot.type === 1){
- depotString = depotString + depot.id + ",";
- }
- }
- depotString = depotString.substring(1, depotString.length-1);
- $("#ProjectId").empty().append(options);
- $("#AllocationProjectId").empty().append(options);
- $("#searchProjectId").empty().append('').append(options);
- }
-}
-
-//初始化供应商、客户、散户信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onLoadSuccess: function(res) {
- var data = $(this).combobox('getData');
- for(var i = 0; i<= data.length; i++){
- if(data && data[i] && data[i].supplier === "非会员"){
- orgDefaultId = data[i].id;
- }
- }
- },
- onSelect: function(rec){
- $.ajax({
- type:"get",
- url: "/supplier/findById",
- data: {
- supplierId: rec.id
- },
- dataType: "json",
- success: function (res){
- if(res && res.code === 200) {
- if(res.data && res.data[0]){
- thisTaxRate = res.data[0].taxRate; //设置当前的税率
- }
- }
- },
- error:function(){
-
- }
- });
- }
- });
-}
-
-//初始化销售人员
-function initSalesman(){
- $('#Salesman').combobox({
- url: "/person/getPersonByNumType?type=1",
- valueField:'id',
- textField:'name',
- multiple: true
- });
-}
-
-//初始化收入项目列表
-function initOutItemList(){
- $.ajax({
- type:"get",
- url: "/inOutItem/findBySelect?type=out",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res){
- if(res){
- outItemList = res;
- }
- },
- error:function(){
-
- }
- });
-}
-
-//初始化商品属性
-function initMProperty(){
- $.ajax({
- type: "get",
- url: "/materialProperty/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- name: ""
- }),
- currentPage: 1,
- pageSize: 100
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- var thisRows = res.data.page.rows;
- for (var i = 0; i < thisRows.length; i++) {
- if (thisRows[i].enabled) {
- mPropertyList += thisRows[i].nativename + ",";
- }
- }
- if (mPropertyList) {
- mPropertyList = mPropertyList.substring(0, mPropertyList.length - 1);
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化系统基础信息
-function initSystemData_person(){
- $.ajax({
- type:"get",
- url: "/person/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- personList = res.data.personList;
- }
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_person(){
- var options1 = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="仓管员")
- {
- options1 += '';
- }
- }
- $("#HandsPersonId").empty().append(options1);
- }
-}
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null){
- options = "";
- options += "";
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- if(account.isdefault) {
- defaultAccountId = account.id; //给账户赋值默认id
- }
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#depotHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- if(pageType === "skip") {
- var oldRowInfo = sessionStorage.getItem("rowInfo");
- editDepotHead(oldRowInfo); //自动弹出编辑框,带缓存数据
- }
- var hideType = undefined;
- var isHiddenStatus = true;
- if(payTypeTitle === "隐藏"){
- hideType = true; //隐藏当前列
- }
- var tableToolBar = [
- {
- id:'addDepotHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addDepotHead();
- }
- },
- {
- id:'deleteDepotHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteDepotHead();
- }
- }
- ];
- //如果允许的按钮列表中存在就显示,3-代表审核|反审核的权限
- if(btnEnableList && btnEnableList.indexOf(3)>-1){
- isHiddenStatus = false; //显示
- tableToolBar.push({
- id:'okDepotHead',
- text:'审核',
- iconCls:'icon-ok',
- handler:function() {
- setStatusFun();
- }
- },
- {
- id:'undoDepotHead',
- text:'反审核',
- iconCls:'icon-undo',
- handler:function() {
- setUnStatusFun();
- }
- });
- }
- else {
- isHiddenStatus = true; //隐藏
- }
- var isShowLastMoneyColumn = true; //是否显示优惠后金额和价税合计,true为隐藏,false为显示
- var isShowOrganNameColumn = false; //是否显示供应商、客户等信息,true为隐藏,false为显示
- var organNameTitle = "会员卡号"; //组织名称标题
- var opWidth = 90; //操作宽度
- var isShowSkip = false; //是否显示跳转按钮
- var opTitle = ""; //跳转按钮的标题
- $('#tableData').datagrid({
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: true,
- //交替出现背景
- striped : true,
- pageSize: 10,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:opWidth,
- formatter:function(value, rec,index) {
- var str = '';
- var orgId = rec.organid? rec.organid:0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
- { title: '单据编号',field: 'number',width:135, formatter:function (value,rec) {
- if(rec.linknumber) {
- return value + "[转]";
- } else {
- return value;
- }
- }
- },
- { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
- if(value) {
- return value.replace(",",",");
- }
- }
- },
- { title: '单据日期',field: 'opertimeStr',width:130},
- { title: '操作员',field: 'operpersonname',width:60},
- { title: '金额合计',field: 'totalprice',width:60},
- { title: '含税合计',field: 'totaltaxlastmoney',hidden:isShowLastMoneyColumn,width:60,formatter:function(value,rec){
- return (rec.discountmoney + rec.discountlastmoney).toFixed(2);
- }
- },
- { title: '优惠后金额',field: 'discountlastmoney',hidden:isShowLastMoneyColumn,width:80},
- { title: payTypeTitle,field: 'changeamount',width:50,hidden:hideType},
- { title: '状态',field: 'status',hidden:isHiddenStatus, width:70,align:"center",formatter:function(value){
- if(value === "0") {
- return "未审核";
- } else if(value === "1") {
- return "已审核";
- } else if(value === "2") {
- }
- }
- }
- ]],
- toolbar:tableToolBar,
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//查找库存的方法
-function findStockNumById(depotId, mId, monthTime, body, input, ratio, type){
- var thisRatio = 1; //比例
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (rec) {
- if(rec && rec.code === 200 && rec.data && rec.data[0]) {
- var loadRatio = 1; //在单位输入框上面加载比例字段
- if(rec.data[0].unit) { //如果存在计量单位信息
- loadRatio = 1;
- }
- else{
- var unitName = rec.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- thisRatio = unitName.substring(unitName.indexOf(":")+1).replace(")","");
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- unitSetInput = rec.data[0].firstoutunit;
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = thisRatio;
- }
- }
- //查询库存
- $.ajax({
- type: "get",
- url: '/depotItem/findStockNumById',
- data:{
- projectId: depotId,
- materialId: mId
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if (res.data && res.data.page && res.data.page[0]) {
- var thisStock = res.data.page[0].thisSum;
- if (type == "select") { //选择下拉框的时候
- if (ratio != undefined && ratio != 1) {
- loadRatio = ratio;
- }
- }
- else if (type == "click") { //点击库存的时候
- if (ratio != undefined) {
- loadRatio = ratio;
- }
- }
- thisStock = (thisStock / loadRatio).toFixed(2);
- body.find("[field='Stock']").find(input).val(thisStock).attr("data-stock", res.data.page[0].thisSum); //加载库存数据
- }
- else {
- body.find("[field='Stock']").find(input).val(0).attr("data-stock", 0); //加载库存数据
- }
- body.find("[field='Stock']").find(input).prop("readonly", "readonly"); //设置库存数据为只读
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
- }
- },
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- }
- });
-}
-//优惠率、合计的统计方法
-function statisticsFun(body,UnitPrice,OperNumber,footer,taxRate){
- var TotalPrice = 0;
- var taxLastMoneyTotal = 0;
- //金额的合计
- body.find("[field='AllPrice']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + UnitPrice*OperNumber;
- footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); //金额的合计
- //价税合计的总计
- body.find("[field='TaxLastMoney']").each(function(){
- if($(this).find("div").text()!==""){
- taxLastMoneyTotal = taxLastMoneyTotal + (parseFloat($(this).find("div").text().toString())-0);
- }
- });
- taxLastMoneyTotal = taxLastMoneyTotal + (UnitPrice*OperNumber*(1+taxRate/100));
- footer.find("[field='TaxLastMoney']").find("div").text((taxLastMoneyTotal).toFixed(2)); //价税合计的页脚总计
- var discount = $("#Discount").val(); //优惠率
- var discountMoney = (taxLastMoneyTotal*discount/100).toFixed(2);
- $("#DiscountMoney").val(discountMoney);//优惠金额
- var discountLastMoney = (taxLastMoneyTotal*(1-discount/100)).toFixed(2)
- $("#DiscountLastMoney").val(discountLastMoney);//优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
-
- $("#ChangeAmount, #getAmount").val((TotalPrice).toFixed(2));
- $("#backAmount").val(0);
-}
-//初始化表格数据-商品列表-编辑状态
-function initTableData_material(type,TotalPrice){
- var body,footer,input; //定义表格和文本框
- var ratio = 1; //比例-品名专用
- var ratioDepot = 1; //比例-仓库用
- var monthTime = getNowFormatMonth();
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var depotHeadName = ""; //仓库名称
- var depotUrl = ""; //仓库接口地址
- var depotTextField = ""; //仓库下拉名称
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var anotherDepotUrl = ""; //对方仓库接口地址
- var anotherDepotTextField = "";
- depotHeadName = "仓库名称";
- depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- depotTextField = "depotName";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialData').datagrid({
- height:245,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: '商品类型',field: 'MType',editor:'validatebox',hidden:isShowMaterialTypeColumn,width:80},
- { title: depotHeadName, field: 'DepotId', editor: 'validatebox', width: 90,
- formatter: function (value, row, index) {
- return row.DepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: depotTextField,
- method: 'get',
- url: depotUrl,
- onSelect:function(rec){
- var depotId = rec.id;
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- if(mId){
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratioDepot, type);
- }
- }
- }
- }
- },
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialId',width:230,
- formatter:function(value,row,index){
- return row.MaterialName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'MaterialName',
- method:'get',
- url: "/material/findBySelect",
- panelWidth: 300, //下拉框的宽度
- //全面模糊匹配,过滤字段
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onBeforeLoad: function(param){
- param.mpList = mPropertyList; //商品属性
- },
- onSelect:function(rec){
- if(rec) {
- var mId = rec.Id;
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (res) {
- if(res && res.code === 200 && res.data && res.data[0]) {
- var retailPrice = res.data[0].retailprice-0; //零售价格
- var presetPriceOne = res.data[0].presetpriceone-0; //预计采购价
- var presetPriceTwo = res.data[0].presetpricetwo-0; //批发价
- var firstInUnit = res.data[0].firstinunit; //首选入库单位
- var firstOutUnit = res.data[0].firstoutunit; //首选出库单位
- var basicPresetPriceOne = ""; //多单位-入库-基础价格
- var basicPresetPriceTwo = ""; //多单位-出库-基础价格
- var retailPriceOne = ""; //多单位-入库-零售价格
- var otherPresetPriceOne = ""; //多单位-入库-其他价格
- var otherPresetPriceTwo = ""; //多单位-出库-其他价格
- var retailPriceTwo = ""; //多单位-出库-零售价格
- var basicUnit = ""; //基础单位
- var otherUnit = ""; //其他单位
- if(!res.data[0].unit){
- var ps = res.data[0].pricestrategy;
- var psObj = JSON.parse(ps);
- basicPresetPriceOne = psObj[0].basic.PresetPriceOne-0;
- basicPresetPriceTwo = psObj[0].basic.PresetPriceTwo-0;
- retailPriceOne = psObj[0].basic.RetailPrice-0;
- otherPresetPriceOne = psObj[1].other.PresetPriceOne-0;
- otherPresetPriceTwo = psObj[1].other.PresetPriceTwo-0;
- retailPriceTwo = psObj[1].other.RetailPrice-0;
- basicUnit = psObj[0].basic.Unit;
- otherUnit = psObj[1].other.Unit;
- }
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- if(res.data[0].unit){ //如果存在计量单位信息
- ratio = 1; //重置比例为1
- body.find("[field='Unit']").find(input).val(res.data[0].unit); //设置-计量单位信息
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- body.find("[field='Unit']").find(input).off("click"); //移除点击事件
- body.find("[field='Unit']").find(input).attr("data-ratio",ratio); //修改比例缓存信息
- }
- else {
- var unitName = res.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- var loadRatio = 1; //在单位输入框上面加载比例字段
- unitSetInput = res.data[0].firstoutunit; //给单位文本框赋值
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = ratio;
- }
- body.find("[field='Unit']").find(input).val(unitSetInput).attr("data-ratio", loadRatio); //设置-首选单位
-
- body.find("[field='Unit']").find(input).off("click").on("click",function(){
- if(basicUnit && otherUnit) {
- var self = this;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- " + basicUnit + "
";
- temp +="- " + otherUnit + "
";
- temp +="
";
- temp +="
";
- if($('.unit-list').length){
- $('.unit-list').remove(); //如果存在计量单位列表先移除
- }
- else {
- $(self).after(temp); //加载列表信息
- }
- //计量单位列表的单击事件
- $('.unit-list ul li').off("click").on("click",function(){
- var unit = $(this).text();
- var thisRatio = $(this).attr("data-ratio"); //获取比例
- $(self).val(unit).attr("data-ratio", thisRatio);
- $(self).keyup(); //模拟键盘操作
- $('.unit-list').remove(); //移除计量单位列表
- var stock = body.find("[field='Stock']").find(input).attr("data-stock"); //从缓存中取值
- var type = $(this).attr("data-type");
- var UnitPrice = 0;
- if(type === "basic"){
- UnitPrice = retailPriceOne;
- body.find("[field='Stock']").find(input).val(stock); //修改库存
- }
- else if(type === "other"){
- UnitPrice = retailPriceTwo;
- body.find("[field='Stock']").find(input).val((stock/ratio).toFixed(2)); //修改库存
- }
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //获取数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击空白处移除计量单位列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.unit-list').remove(); //移除计量单位列表
- });
- }
- });
- }
- var detailPrice = 0; //明细列表-单价
- if(res.data[0].unit) { //如果存在计量单位信息
- detailPrice = retailPrice;
- }
- else {
- if (firstOutUnit == basicUnit) {
- detailPrice = retailPriceOne;
- }
- else if (firstOutUnit == otherUnit) {
- detailPrice = retailPriceTwo;
- }
- }
- body.find("[field='OperNumber']").find(input).val(1); //数量初始化为1
- //单价和总价赋值
- if(!detailPrice) {
- detailPrice = 0;
- }
- body.find("[field='UnitPrice']").find(input).val(detailPrice);
- body.find("[field='AllPrice']").find(input).val(detailPrice);
- var taxRate = body.find("[field='TaxRate']").find(input).val()-0; //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((detailPrice*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,detailPrice,1,footer,taxRate);
-
- //查询库存信息
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- if(depotId) {
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, loadRatio, type);
- }
- }
- },
- error: function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- }
- });
- }
- }
- }
- }
- },
- { title: '库存',field: 'Stock',editor:'validatebox',width:70},
- { title: anotherDepotHeadName, field: 'AnotherDepotId',editor:'validatebox',hidden:isShowAnotherDepot,width:90,
- formatter: function (value, row, index) {
- return row.AnotherDepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: anotherDepotTextField,
- method: 'get',
- url: anotherDepotUrl
- }
- }
- },
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率(%)',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batchDel(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = 0;
- var TaxLastMoney = 0;
- var DiscountMoney = $("#DiscountMoney").val()-0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoney").val()-0; //优惠后金额
- if(type === "edit") {
- AllPrice = TotalPrice;
- TaxLastMoney = DiscountMoney + DiscountLastMoney;
- }
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": TaxLastMoney
- });
- data.footer = array;
- $("#materialData").datagrid('loadData',data);
- //如果是订单跳转到采购或销售
- if(pageType === "skip") {
- var skipList = $("#depotHeadFM .datagrid-body tr");
- //逐条自动点击每行数据
- skipList.each(function (i) {
- setTimeout(function () {
- skipList.eq(i).find("[field='Stock']").click();
- },(i+1)*1000);
- });
- }
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//初始化表格数据-商品列表-查看状态
-function initTableData_material_show(TotalPrice){
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var depotHeadName = ""; //仓库的列的标题
- depotHeadName = "仓库名称";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialDataShow').datagrid({
- height:245,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- onClickRow: onClickRow,
- columns:[[
- { title: '商品类型',field: 'MType',width:80, hidden:isShowMaterialTypeColumn},
- { title: depotHeadName,field: 'DepotName',editor:'validatebox',width:90},
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialName',width:230},
- { title: anotherDepotHeadName,field: 'AnotherDepotName',hidden:isShowAnotherDepot,width:90},
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validattebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = TotalPrice;
- var DiscountMoney = $("#DiscountMoneyShow").text() - 0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoneyShow").text() - 0; //优惠后金额
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": DiscountMoney + DiscountLastMoney
- });
- data.footer = array;
- $("#materialDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showDepotHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除单据信息
-function deleteDepotHead(depotHeadID, thisOrganId, totalPrice, status){
- if(status == "1" || status == "2") {
- $.messager.alert('删除提示','已审核和已转的单据不能删除!','warning');
- return;
- }
- $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
- if (r) {
- $.ajax({
- type:"post",
- url: "/depotHead/deleteDepotHeadAndDetail",
- dataType: "json",
- data:{
- id: depotHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
- return;
- }
- });
-
- //更新会员的预收款信息
- if(listSubType === "零售") {
- $.ajax({
- type:"post",
- url: "/supplier/updateAdvanceIn",
- dataType: "json",
- data:{
- supplierId: thisOrganId, //会员id
- advanceIn: totalPrice //删除时同时返还用户的预付款
- },
- success: function(res){
- if(res && res.code === 200) {
- //保存会员预收款成功
- }
- },
- error: function(){
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- }
- });
-}
-
-//订单转采购或销售
-function skipDepotHead(index, status){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- if(status == "0" || status == "2") {
- $.messager.alert('提示','未审核和已转的单据禁止操作!','warning');
- } else {
- sessionStorage.setItem("rowInfo", JSON.stringify(rowsdata)); //将单据信息存入缓存中
- }
-}
-
-//批量删除单据信息
-function batDeleteDepotHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条单据信息吗?',function(r)
- {
- if (r) {
- var ids = "";
- for (var i = 0; i < row.length; i++) {
- if (i == row.length - 1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- if (ids) {
- //批量删除
- $.ajax({
- type: "post",
- // url: "/depotHead/batchDelete",
- url: "/depotHead/batchDeleteDepotHeadAndDetail",
- dataType: "json",
- async: false,
- data: ({
- ids: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除单据信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('删除提示','没有能删除的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量审核
-function setStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('审核确认','确定要审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: "1",
- depotHeadIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('审核提示', '审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('审核提示','审核信息异常,请稍后再试!','error');
- return;
- }
- });
- } else {
- $.messager.alert('审核提示','没有能审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量反审核
-function setUnStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('反审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('反审核确认','确定要反审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type: "post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async: false,
- data: ({
- status: "0",
- depotHeadIDs: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('反审核提示', '反审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('反审核提示', '反审核信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('反审核提示','没有能反审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//生成单据编号
-function buildNumber() {
- $.ajax({
- type: "get",
- url: "/depotHead/buildNumber",
- success:function(res){
- if(res && res.code === 200){
- var obj = res.data;
- var defaultNumber = obj.DefaultNumber;
- var newNumber = amountNum + defaultNumber;
- $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
- }
- },
- error:function(){
- $.messager.alert('提示','生成单据编号失败!','error');
- }
- });
-}
-
-//新增信息
-function addDepotHead(){
- $('#depotHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- buildNumber(); //生成单据编号
- //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为0
- $("#Discount").val(0);
- $("#DiscountMoney").val(0);
- $("#DiscountLastMoney").val(0);
- $("#ChangeAmount").val(0);
- $("#Debt").val(0);
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- var addTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgDepotHead = "";
- depotHeadID = 0;
- initTableData_material("add"); //商品列表
- reject(); //撤销下、刷新商品列表
- $("#addOrgan").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加供应商信息');
- $('#supplierFM').form('clear');
- });
-
- $("#addMember").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加会员信息');
- $('#supplierFM').form('clear');
- });
- $("#addCustomer").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加客户信息');
- $('#supplierFM').form('clear');
- });
- url = '/depotHead/addDepotHeadAndDetail';
-
- //零售单据修改收款时,自动计算找零
- $("#payType").val("现付");
- $("#OrganId").combobox("setValue", orgDefaultId); //自动默认选择非会员
- // 鼠标点下时清空选择项
- $("#OrganId").next().find("input").off("mousedown").on("mousedown",function(){
- $("#OrganId").combobox("setValue", "");
- });
- //当会员卡号长度超过10位后,自动点击下拉框,用于兼容刷卡器
- $("#OrganId").next().find("input").off("keyup").on("keyup",function(){
- var self = this;
- if($(this).val().length === 10){
- setTimeout(function(){
- $(".combo-panel .combobox-item-selected").click();
- //更新付款类型,加载会员的预付款的金额
- for(var i=0; i0){
- option = '';
- option += '';
- }
- else {
- option += '';
- }
- $("#payType").empty().append(option);
- }
- }
- },1000);
- }
- });
- var getAmount = $("#depotHeadFM .get-amount");
- var changeAmount = $("#depotHeadFM .change-amount");
- var backAmount = $("#depotHeadFM .back-amount");
- getAmount.val(0); changeAmount.val(0); backAmount.val(0); //时间初始化
- getAmount.off("keyup").on("keyup",function() {
- if(changeAmount.val()){
- backAmount.val((getAmount.val()-changeAmount.val()).toFixed(2));
- }
- });
-}
-
-//编辑信息
-function editDepotHead(index, status){
- if(status == "1" || status == "2") {
- $.messager.alert('编辑提示','已审核和已转的单据不能编辑!','warning');
- return;
- }
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata ='';
- if(Number(index).toString()=='NaN'){
- rowsdata=$.parseJSON(index);
- }else{
- rowsdata=$("#tableData").datagrid("getRows")[index];
- }
- $("#ProjectId").focus().val(rowsdata.projectid);
- var ProjectId=rowsdata.projectid;
- if(ProjectId!='') {
- initSystemData_person(ProjectId);
- initSelectInfo_person();
- }
- var TotalPrice = rowsdata.totalprice; //合计金额
- if(pageType === "skip") { //从订单跳转过来
- buildNumber(); //生成单据编号
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- $("#LinkNumber").val(rowsdata.number); //关联订单号
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- $("#DiscountLastMoney").val(TotalPrice); //优惠后金额
- $("#ChangeAmount").val(TotalPrice).attr("data-changeamount", TotalPrice);
- } else {
- $("#Number").val(rowsdata.number).attr("data-defaultNumber",rowsdata.number);
- $("#OperTime").val(rowsdata.opertimeStr);
- $("#LinkNumber").val(rowsdata.linknumber==undefined?"":rowsdata.linknumber); //关联订单号
- $("#AccountId").val(rowsdata.accountid); //账户Id
- $("#DiscountLastMoney").val(rowsdata.discountlastmoney==undefined?"0.00":rowsdata.discountlastmoney); //优惠后金额
- $("#ChangeAmount").val(rowsdata.changeamount).attr("data-changeamount", rowsdata.changeamount);
- }
- $('#OrganId').combobox('setValue', rowsdata.organid==undefined?'':rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#Remark").val(rowsdata.remark);
- $("#Discount").val(rowsdata.discount==undefined?"0":rowsdata.discount);
- $("#DiscountMoney").val(rowsdata.discountmoney==undefined?"0.00":rowsdata.discountmoney);
- $("#Debt").val(Number((rowsdata.discountlastmoney==undefined?'0.00':rowsdata.discountlastmoney-rowsdata.changeamount)).toFixed(2));
- $("#AccountDay").val(rowsdata.accountday==undefined?"":rowsdata.accountday); //结算天数
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于扣预付款
- $("#AllocationProjectId").val(rowsdata.allocationprojectid);
- oldNumber = rowsdata.number; //记录编辑前的单据编号
- oldId = rowsdata.id; //记录单据Id
- var editTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- depotHeadID = rowsdata.id;
-
- //采购入库、销售出库的多账户加载
- if(rowsdata.accountidlist!=undefined && rowsdata.accountmoneylist!=undefined){
- $("#AccountId").val("many"); //下拉框选中多账户
- var accountArr = rowsdata.accountidlist.split(",");
- var accountMoneyArr = rowsdata.accountmoneylist.split(",");
- accountMoneyArr = changeListFmtPlus(accountMoneyArr) //将数组单个金额中的数值转为正数
-
- var manyAccountMoney = 0; //多账户合计-零售
- for (var j = 0; j < accountArr.length; j++) {
- if (accountList != null) {
- for (var i = 0; i < accountList.length; i++) {
- var account = accountList[i];
- if (accountArr[j] == account.id) {
- manyAccountMoney += accountMoneyArr[j] - 0; //多账户合计-零售
- }
- }
- }
- }
- $("#getAmount").val(manyAccountMoney); //收款金额、付款金额
- var changeAmount = $("#ChangeAmount").val()-0;
- $("#backAmount").val((manyAccountMoney-changeAmount).toFixed(2)); //找零
-
- $("#AccountId").attr("data-accountArr", JSON.stringify(accountArr)).attr("data-accountMoneyArr", JSON.stringify(accountMoneyArr)); //json数据存储
- $(".many-account-ico").show(); //显示多账户的ico图标
- }
-
- //采购入库、销售出库的费用数据加载
- if(rowsdata.othermoneylist &&rowsdata.othermoneyitem){
- $("#OtherMoney").val(rowsdata.othermoney==undefined?"0":rowsdata.othermoney); //采购费用、销售费用
- var itemArr = rowsdata.othermoneylist.split(",");
- var itemMoneyArr = rowsdata.othermoneyitem.split(",");
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
-
- initTableData_material("edit",TotalPrice); //商品列表
- reject(); //撤销下、刷新商品列表
- if(pageType === "skip") {
- url = '/depotHead/addDepotHeadAndDetail'; //如果是从订单跳转过来,则此处为新增的接口
- //jshjshjsh
- $("#depotHeadFM .datagrid-body").find("[field='DepotId']").click();
- } else {
- url = '/depotHead/updateDepotHeadAndDetail?id=' + rowsdata.id; //更新接口
- }
-}
-
-//查看信息
-function showDepotHead(index){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var manyAccountMoney = 0; //多账户合计-零售
- $("#ProjectIdShow").text(rowsdata.projectName);
- $("#NumberShow").text(rowsdata.number);
- $("#OperTimeShow").text(rowsdata.opertimeStr);
- $('#OrganIdShow').text(rowsdata.organName==undefined?'':rowsdata.organName);
- $("#HandsPersonIdShow").text(rowsdata.handsPersonName);
- if(rowsdata.accountName && rowsdata.accountName!=undefined){
- $("#AccountIdShow").text(rowsdata.accountName); //结算账户
- } else {
- var accountArr = (rowsdata.accountidlist==undefined?"":rowsdata.accountidlist).split(","); //账户id列表
- var accountMoneyArr =(rowsdata.accountmoneylist==undefined?"":rowsdata.accountmoneylist).split(","); //账户金额列表
- var accountIdShow = "";
- for(var j =0;j 查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- depotHeadID = rowsdata.id;
- initTableData_material_show(TotalPrice); //商品列表-查看状态
-
-//零售单据展示数据
- var changeAccount = $("#depotHeadDlgShow .change-amount-show").text() -0;
- if(manyAccountMoney!==0){
- $("#depotHeadDlgShow .get-amount-show").text((manyAccountMoney).toFixed(2));
- $("#depotHeadDlgShow .back-amount-show").text((manyAccountMoney -changeAccount).toFixed(2));
- }
- else {
- $("#depotHeadDlgShow .get-amount-show").text((changeAccount).toFixed(2));
- $("#depotHeadDlgShow .back-amount-show").text(0);
- }
-}
-
-//绑定操作事件
-function bindEvent(){
- showDepotHeadDetails(1,initPageSize); //初始化时自动查询
- //搜索处理
- $("#searchBtn").off("click").on("click",function(){
- showDepotHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh',
- {
- pageNumber:1,
- pageSize:initPageSize
- });
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- //$("#searchProjectId").val("");
- $("#searchState").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //检查单据编号是否存在
- function checkDepotHeadNumber() {
- var thisNumber = $.trim($("#Number").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(thisNumber.length > 0 &&( oldNumber.length ==0 || thisNumber != oldNumber))
- {
- $.ajax({
- type:"get",
- url: "/depotHead/checkIsNumberExist",
- dataType: "json",
- async : false,
- data: ({
- DepotHeadID : oldId,
- Number : thisNumber
- }),
- success: function (tipInfo)
- {
- flag = tipInfo;
- if(tipInfo)
- {
- $.messager.alert('提示','抱歉,该单据编号已经存在','warning');
- return;
- }
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','检查单据编号是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
- //保存信息
- /**
- * 2019-01-25
- * 我对这个方法的实现结果存在严重怀疑,决定重构
- * 有如下疑点:
- * 1、保存完主表,返回结果后,再发起请求去操作子表,如何保证事务的一致性(业务数据一致性)
- * 2、保存完主表后,再通过selectmax的方式去获取主表主键id完全就是看人品的不可靠的思路
- * 修改计划:
- * 2019-01-25修改零售出库相关操作
- * 修改方式,重写url,将主从表操作合并
- *
- *
- * **/
- $("#saveDepotHead").off("click").on("click",function(){
- if(!$('#depotHeadFM').form('validate')){
- return;
- }
- else {
- //如果初始编号被修改了,就要判断单据编号是否存在
- if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
- //调用查询单据编号是否重名的方法
- if(checkDepotHeadNumber()){
- return;
- }
- }
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择退货单位!','warning');
- return;
- }
- if(!$('#AccountId').val()){
- $.messager.alert('提示','请选择付款账户!','warning');
- return;
- }
- if (editIndex != undefined) {
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- //进行明细的校验
- if(depotHeadID ==0) {
- //新增模式下
- if (!CheckData("add")) {
- return;
- }
- }
- else {
- //编辑模式下
- if (!CheckData("edit")) {
- return;
- }
- }
- var OrganId = null, ProjectId = null,AllocationProjectId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val())-0;
- var TotalPrice = $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text();
- if($('#OrganId').length){
- OrganId = $('#OrganId').combobox('getValue');
- }
- var accountMoneyList = $("#AccountId").attr("data-accountmoneyarr"); //账户金额列表-多账户
- var accountMoneyArr;
- if(accountMoneyList) {
- accountMoneyList = accountMoneyList.replace("[","").replace("]","").toString();
- var reg=new RegExp("\"","g"); //创建正则RegExp对象
- accountMoneyList = accountMoneyList.replace(reg,""); //替换所有的双引号
- accountMoneyArr = accountMoneyList.split(","); //转为数组
- }
- //付款为负数
- ChangeAmount = 0 - ChangeAmount;
- TotalPrice = 0 - TotalPrice;
- if(accountMoneyArr) {
- accountMoneyArr = changeListFmtMinus(accountMoneyArr); //将数组单个金额中的数值转为负数
- }
- //零售时候,可以从会员预付款中扣款
- var thisPayType = "现付";
- var SalesmanStr = "";
- var getAccountID = $.trim($("#AccountId").val());
- if($("#AccountId").val() === "many"){ //多账户
- getAccountID = null;
- }
- var infoStr=JSON.stringify({
- Type: listType,
- SubType: listSubType,
- ProjectId: ProjectId,
- AllocationProjectId: AllocationProjectId,
- DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
- Number: $.trim($("#Number").val()),
- LinkNumber: $.trim($("#LinkNumber").val()),
- OperTime: $("#OperTime").val(),
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Salesman: SalesmanStr, //销售人员
- AccountId: getAccountID,
- ChangeAmount: ChangeAmount, //付款/收款
- TotalPrice: TotalPrice, //合计
- PayType: thisPayType, //现付/预付款
- Remark: $.trim($("#Remark").val()),
- AccountIdList: $("#AccountId").attr("data-accountarr"), //账户列表-多账户
- AccountMoneyList: accountMoneyArr ? JSON.stringify(accountMoneyArr) : "", //账户金额列表-多账户
- Discount: $.trim($("#Discount").val()),
- DiscountMoney: $.trim($("#DiscountMoney").val()),
- DiscountLastMoney: $.trim($("#DiscountLastMoney").val()),
- OtherMoney: $.trim($("#OtherMoney").val()), //采购费用、销售费用
- OtherMoneyList: $("#OtherMoney").attr("data-itemarr"), //支出项目列表-涉及费用
- OtherMoneyItem: $("#OtherMoney").attr("data-itemmoneyarr"), //支出项目金额列表-涉及费用
- AccountDay: $("#AccountDay").val() //结算天数
- });
- /**
- * 零售出库,单独操作
- * */
- if(url.indexOf("/depotHead/addDepotHeadAndDetail")>=0){
- addDepotHeadAndDetail(url,infoStr);
- return;
- }else if(url.indexOf("/depotHead/updateDepotHeadAndDetail")>=0){
- updateDepotHeadAndDetail(url,infoStr,preTotalPrice);
- return;
- }
- }
- });
-
- //打印单据
- $("#printDepotHeadShow").off("click").on("click",function(){
- var tableString = $("#depotHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event){
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="State"||obj.id=="Number"))
- {
- $("#saveDepotHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber"||obj.id=="searchMaterial"))
- {
- $("#searchBtn").click();
- }
- });
-
- //优惠率输入框事件
- $("#Discount").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountNum = $(this).val();
- var discountMoney = (discountNum/100*totalPrice).toFixed(2);
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#DiscountMoney").val(discountMoney); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //优惠金额输入框事件
- $("#DiscountMoney").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountMoney = $(this).val();
- var discount = (discountMoney/totalPrice).toFixed(2)*100;
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#Discount").val(discount); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //付款、收款输入框事件
- $("#ChangeAmount").off("keyup").on("keyup",function(){
- var discountLastMoney = $("#DiscountLastMoney").val();
- var changeAmount = $(this).val();
- var debtMoney = (discountLastMoney - changeAmount).toFixed(2);
- $("#Debt").val(debtMoney); //本次欠款
- });
-
- //多账户结算窗口弹出事件
- function depotHeadAccountDlgFun(){
- $('#depotHeadAccountDlg').dialog('open').dialog('setTitle','
多账户结算');
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").remove(); //先移除输入栏目
- $("#accountMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#depotHeadAccountDlg .tabs-tmp .account-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#depotHeadAccountDlg .tabs-tmp tbody").html();
- var accountDlgHead = $("#depotHeadAccountDlg .account-head-tmp");
- accountDlgHead.after(contentTmp);
- }
-
- //获取账户信息
- function accountDlgFun() {
- var options = "";
- if(accountList !=null){
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- }
- $(".account-id-dlg").empty().append("").append(options);
- }
- }
- accountDlgFun(); //获取账户信息
- $("#depotHeadAccountDlg .tabs-tmp").hide(); //隐藏模板
-
- //账户金额输入框事件-多账户
- $("#depotHeadAccountDlg .account-dlg .account-money-dlg").off("keyup").on("keyup",function(){
- var totalAccoutNum = 0;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var eachAccountMoney = $(this).find(".account-money-dlg").val()-0;
- totalAccoutNum += eachAccountMoney;
- });
- $("#accountMoneyTotalDlg").text(totalAccoutNum);
- });
-
- //结算多账户列表的切换事件
- $("#depotHeadAccountDlg .account-dlg .account-id-dlg").off("change").on("change",function(){
- var selectAccount = $(this).children('option:selected').text();
- if(selectAccount === ""){
- var thisMoneyDom = $(this).closest(".account-content-tmp").find(".account-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text() - 0;
- $("#accountMoneyTotalDlg").text(accountMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //账户为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveDepotHeadAccountDlg").off("click").on("click", function(){
- //完成多账户的json数据存储
- var accountArr = []; //账户id数组
- var accountMoneyArr = []; //账户金额数组
- var errorIndex = -1;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var thisAccId = $(this).find(".account-id-dlg").val();
- var thisAccMoney = $(this).find(".account-money-dlg").val();
- if(!thisAccId && thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && !thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && thisAccMoney) {
- accountArr.push(thisAccId);
- accountMoneyArr.push(thisAccMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var discountLastMoneyNum =$("#DiscountLastMoney").val()-0; //优惠后金额
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text()-0; //本次付款或者收款
- if(accountMoneyTotal===0){
- $.messager.alert('错误提示',"请填写金额后保存",'warning');
- return;
- }
- if(accountArr.length && accountMoneyArr.length) {
- $("#AccountId").attr("data-accountArr",JSON.stringify(accountArr)).attr("data-accountMoneyArr",JSON.stringify(accountMoneyArr)); //json数据存储
- }
- $("#getAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
- var backAmount = $("#getAmount").val() - $("#ChangeAmount").val();
- $("#backAmount").val((backAmount - 0).toFixed(2)); //计算找零金额
- $("#Debt").val((discountLastMoneyNum-accountMoneyTotal).toFixed(2)); //本次欠款
- $("#depotHeadAccountDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#AccountId").attr("data-accountArr")){
- $("#depotHeadAccountDlg").dialog('close');
- }
- else {
- $("#depotHeadAccountDlg").dialog('close');
- $("#AccountId").val("").removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").prop("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- }
- //多账户-取消按钮
- $("#cancelDepotHeadAccountDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //多账户-右上角的关闭按钮
- $("#depotHeadAccountDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
- }
- //点击多账户,弹出输入框
- $("#AccountId").off("change").on("change",function(){
- var selectText = $(this).children('option:selected').text();
- if(selectText === "多账户"){
- $("#ChangeAmount").prop("readonly","readonly");
- depotHeadAccountDlgFun();
- $(".many-account-ico").show(); //显示多账户小图标
- }
- else{
- $(this).removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").prop("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- });
-
- //结算账户-多账户小图标-点击事件
- $(".many-account-ico").off("click").on("click",function(){
- depotHeadAccountDlgFun();
- //给弹窗赋值-多账户数据
- var accountArr = $("#AccountId").attr("data-accountArr");
- accountArr = JSON.parse(accountArr);
- var accountMoneyArr = $("#AccountId").attr("data-accountMoneyArr");
- accountMoneyArr = JSON.parse(accountMoneyArr);
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".account-id-dlg").val(accountArr[index]);
- $(this).find(".account-money-dlg").val(accountMoneyArr[index]);
- });
- $("#accountMoneyTotalDlg").text($("#getAmount").val());
- });
-
- //点击采购费用、销售费用的事件
- $(".other-money-ico").off("click").on("click",function(){
- $('#otherMoneyDlg').dialog('open').dialog('setTitle','
'+ listSubType +'费用');
- $("#otherMoneyDlg .money-dlg .money-content-tmp").remove(); //先移除输入栏目
- $("#otherMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#otherMoneyDlg .tabs-tmp .money-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#otherMoneyDlg .tabs-tmp tbody").html();
- var moneyDlgHead = $("#otherMoneyDlg .money-head-tmp");
- moneyDlgHead.after(contentTmp);
- }
-
- //获取支出项目信息
- function moneyDlgFun() {
- var options = "";
- if(outItemList !=null){
- for(var i = 0 ;i < outItemList.length;i++) {
- var money = outItemList[i];
- options += '';
- }
- $(".money-id-dlg").empty().append("").append(options);
- }
- }
- moneyDlgFun(); //获取支出项目信息
- $("#otherMoneyDlg .tabs-tmp").hide(); //隐藏模板
-
- //支出项目的金额输入框事件
- $("#otherMoneyDlg .money-dlg .other-money-dlg").off("keyup").on("keyup",function(){
- var totalMoneyNum = 0;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var eachOtherMoney = $(this).find(".other-money-dlg").val()-0;
- totalMoneyNum += eachOtherMoney;
- });
- $("#otherMoneyTotalDlg").text(totalMoneyNum);
- });
-
- //支出项目列表的切换事件
- $("#otherMoneyDlg .money-dlg .money-id-dlg").off("change").on("change",function(){
- var selectItem = $(this).children('option:selected').text();
- if(selectItem === ""){
- var thisMoneyDom = $(this).closest(".money-content-tmp").find(".other-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text() - 0;
- $("#otherMoneyTotalDlg").text(otherMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //支出项目为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveOtherMoneyDlg").off("click").on("click", function(){
- //完成支出项目的json数据存储
- var itemArr = []; //支出项目id数组
- var itemMoneyArr = []; //支出项目金额数组
- var errorIndex = -1;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var thisId = $(this).find(".money-id-dlg").val();
- var thisMoney = $(this).find(".other-money-dlg").val();
- if(!thisId && thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && !thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && thisMoney) {
- itemArr.push(thisId);
- itemMoneyArr.push(thisMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text()-0; //合计金额
- if(otherMoneyTotal === 0){ //0的时候清空缓存数据
- $("#OtherMoney").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr");
- }
- if(itemArr.length && itemMoneyArr.length) {
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
- $("#OtherMoney").val(otherMoneyTotal); //给采购费用、销售费用赋值
- $("#otherMoneyDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#OtherMoney").attr("data-itemArr")){
- $("#otherMoneyDlg").dialog('close');
- }
- else {
- $("#otherMoneyDlg").dialog('close');
- $("#OtherMoney").val("").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr"); //将下拉置空并把缓存参数清空
- }
- }
- //费用-取消按钮
- $("#cancelOtherMoneyDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //费用-右上角的关闭按钮
- $("#otherMoneyDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
-
- //给弹窗赋值-采购费用、销售费用数据
- var itemArr = $("#OtherMoney").attr("data-itemArr");
- itemArr = JSON.parse(itemArr);
- var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr");
- itemMoneyArr = JSON.parse(itemMoneyArr);
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".money-id-dlg").val(itemArr[index]);
- if(itemMoneyArr[index]!="undefined"){
- $(this).find(".other-money-dlg").val(itemMoneyArr[index]);
- }
- });
- $("#otherMoneyTotalDlg").text($("#OtherMoney").val());
- });
-
-}
-
-function showDepotHeadDetails(pageNo,pageSize){
- var materialParam = $.trim($("#searchMaterial").val());
- var beginTime = $.trim($("#searchBeginTime").val());
- var endTime = $.trim($("#searchEndTime").val());
- if(beginTime) {
- beginTime = beginTime + ' 00:00:00';
- }
- if(endTime) {
- endTime = endTime + ' 23:59:59';
- }
- $.ajax({
- type: "get",
- url: "/depotHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- subType: listSubType,
- state: $.trim($("#searchState").val()),
- number: $.trim($("#searchNumber").val()),
- beginTime: beginTime,
- endTime: endTime,
- materialParam: materialParam,
- depotIds: depotString
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- return;
- }
- });
-}
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#depotHeadFM .datagrid-body");
- var footer =$("#depotHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
- //点击商品下拉框,自动加载数量、单价、金额
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //点击库存文本框,字段计算库存
- body.find("[field='Stock']").find(input).off("click").on("click",function(){
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- var monthTime = getNowFormatMonth();
- if(depotId && mId){
- var ratio = body.find("[field='Unit']").find(input).attr("data-ratio");
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //在新增的时候,这个ratio有值;在编辑的时候,这个ratio为undefined
- var type = "click"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratio, type);
- }
- else{
- body.find("[field='Stock']").find(input).val(0).attr("data-stock",0); //加载库存数据
- }
- });
- //修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计
- body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber =$(this).val()-0; //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
-
- });
- //修改单价,自动计算金额和合计
- body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice =$(this).val()-0; //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击单价,自动提示参考价格列表
- body.find("[field='UnitPrice']").find(input).off("click").on("click",function(){
- var self = this;
- var mValue = body.find("[field='MaterialId'] .combo-value").attr("value"); //获取选中的商品id
- if(!mValue) {
- return;
- }
- else {
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mValue - 0
- },
- success: function(res){
- if(res && res.rows && res.rows[0]) {
- var retailPrice = res.rows[0].RetailPrice;
- var presetPriceOne = res.rows[0].PresetPriceOne;
- var presetPriceTwo = res.rows[0].PresetPriceTwo;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- 批发价:" + presetPriceTwo + "
";
- temp +="- 零售价:" + retailPrice + "
";
- temp +="
";
- temp +="
";
- if($('.price-list').length){
- $('.price-list').remove(); //如果存在价格列表先移除
- }
- else {
- if(presetPriceTwo != undefined){ //多单位的商品
- $(self).after(temp); //加载列表信息
- }
- }
- $('.price-list ul li').off("click").on("click",function(){
- var price = $(this).text();
- price = price.substring(price.indexOf(":") + 1);
- $(self).val(price);
- $(self).keyup(); //模拟键盘操作
- $('.price-list').remove(); //移除价格列表
- });
- //点击空白处移除价格列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.price-list').remove(); //移除价格列表
- });
- }
- },
- error: function(){
- $.messager.alert('错误提示','查询商品信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- //修改含税单价,自动计算单价、金额、税额、价税合计和合计
- body.find("[field='TaxUnitPrice']").find(input).off("keyup").on("keyup",function(){
- var TaxUnitPrice =$(this).val()-0; //含税单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var UnitPrice = TaxUnitPrice/(1+taxRate/100); //计算单价
- body.find("[field='UnitPrice']").find(input).val((UnitPrice).toFixed(2)); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改金额,自动计算单价、税额、价税合计和合计
- body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var AllPrice =$(this).val()-0; //金额
- var UnitPrice = (AllPrice/OperNumber).toFixed(2);
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税率,自动计算含税单价、税额、价税合计和合计
- body.find("[field='TaxRate']").find(input).off("keyup").on("keyup",function(){
- var taxRate =$(this).val()-0; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税额,自动计算税率、含税单价、价税合计和合计
- body.find("[field='TaxMoney']").find(input).off("keyup").on("keyup",function(){
- var taxMoney =$(this).val()-0; //税额
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = taxMoney/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改价税合计,自动计算税率、含税单价、税额和合计
- body.find("[field='TaxLastMoney']").find(input).off("keyup").on("keyup",function(){
- var taxLastMoney =$(this).val()-0; //价税合计
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = (taxLastMoney-AllPrice)/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
-
- //加载税率
- if(thisTaxRate) {
- body.find("[field='TaxRate']").find(input).val(thisTaxRate);
- }
- else {
- body.find("[field='TaxRate']").find(input).val(0); //默认为0
- }
-
- //在商品类型加载 组装件、普通子件
- var mType = body.find("[field='MType']");
- var rowListLength = mType.find(input).closest(".datagrid-row").attr("datagrid-row-index");
- var mTypeValue = "组合件";
- if(rowListLength > 0){
- mTypeValue = "普通子件";
- }
- },500);
-}
-
-//结束编辑
-function endEditing() {
- if (editIndex == undefined) { return true }
- if ($('#materialData').datagrid('validateRow', editIndex)) {
- //仓库信息
- var edDepot = $('#materialData').datagrid('getEditor', {index:editIndex,field:'DepotId'});
- var DepotName = $(edDepot.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName;
- //商品信息
- var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'});
- var MaterialName = $(edMaterial.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName;
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#materialData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append(){
- if (endEditing()) {
- $('#materialData').datagrid('appendRow', {DepotId:defDepotId});
- editIndex = $('#materialData').datagrid('getRows').length - 1;
- $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function batchDel(){
- /**
- * 重写一下删除的逻辑
- * 获取所有选中行,直接从列表中移除
- * 点击保存时,将需要后台删除的数据提交到服务器
- * **/
- /**
- * create by: qiankunpingtai
- * create time: 2019/3/20 16:26
- * description:
- * 这个地方比较坑的,花了一个多小时才搞明白为什么
- * 1、删除之前必须先调用endEditing结束编辑
- * 2、如果只是调用endEditing结束编辑那么正在编辑行的被选中状态会被去掉
- * 所以要在调用endEditing先获取选中的行
- */
- //如果编辑的行一开始是选中状态,结束编辑后仍然是选中状态
- var row = $('#materialData').datagrid('getChecked');
- if (endEditing()) {
- if (row.length == 0) {
- $.messager.alert('删除提示', '没有记录被选中!', 'info');
- return;
- }
- if (row.length > 0) {
- $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条单据信息吗?', function (r) {
- if (r) {
- for (var i = 0; i < row.length; i++) {
- $('#materialData').datagrid('deleteRow', $('#materialData').datagrid("getRowIndex", row[i]));
- }
- }
- });
- }
- }
-}
-function removeit(){
- if (editIndex == undefined) { return }
- $('#materialData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#materialData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData(type) {
- var change = $('#materialData').datagrid('getChanges').length;
- if(type =="add" && !change) {
- $.messager.alert('提示','请输入明细信息!','warning');
- return false;
- }
- var row = $('#materialData').datagrid('getRows');
- if(!row.length){
- $.messager.alert('提示',"请输入明细信息!",'info');
- return false;
- }
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if (row[i].DepotId == "" || row[i].MaterialId == "" || row[i].OperNumber == "" || row[i].UnitPrice === "" || row[i].AllPrice === "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-
-/**
- * 新增单据主表及单据子表
- * */
-function addDepotHeadAndDetail(url,infoStr){
- var inserted = null;
- if(pageType === "skip") {
- inserted = $("#materialData").datagrid('getChanges', "updated");
- } else {
- inserted = $("#materialData").datagrid('getChanges', "inserted");
- }
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated)
- }),
- success: function (tipInfo){
-
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
-
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
-
-
- });
-}
-/**
- * 修改单据主表及单据子表
- * */
-function updateDepotHeadAndDetail(url,infoStr,preTotalPrice){
- var inserted = $("#materialData").datagrid('getChanges', "inserted");
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- id:url.substring(url.lastIndexOf("?id=")+4,url.length),
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- preTotalPrice:preTotalPrice
- }),
- success: function (tipInfo){
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
- if (endEditing()) {
- $('#materialData').datagrid('acceptChanges');
- }
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-
-
-
diff --git a/erp_web/js/pages/materials/retail_out_list.js b/erp_web/js/pages/materials/retail_out_list.js
deleted file mode 100644
index 6413aa48..00000000
--- a/erp_web/js/pages/materials/retail_out_list.js
+++ /dev/null
@@ -1,2556 +0,0 @@
-//初始化界面
-var defDepotId = null;
-var kid = sessionStorage.getItem("userId");
-var pageType = getUrlParam('t'); //获取页面类型传值
-var depotList = null;
-var depotID = null;
-var supplierList = null;
-var supplierID = null;
-var personList = null;
-var personID = null;
-var ProjectSearch=null;
-var userBusinessList=null;
-var userdepot=null;
-var url;
-var depotHeadID = 0;
-var preTotalPrice = 0; //前一次加载的金额
-var orgDepotHead = "";
-var editIndex = undefined;
-/**默认编号有意义吗,不如空着吧*/
-var orgDefaultId=''; //单位默认编号
-var orgDefaultList; //存储查询出来的会员列表
-var accountList; //账户列表
-var outItemList; //支出项目列表
-var thisTaxRate = 0; //当前税率,选择供应商或者客户的时候设置
-var oldNumber = ""; //编辑前的单据编号
-var oldId = 0; //编辑前的单据Id
-var otherColumns = true; //明细中的‘别名’列是否显示
-var btnEnableList = getBtnStr(); //获取按钮的权限
-var mPropertyList = ""; //商品属性列表
-var defaultAccountId = 0; //默认账户id
-//改变宽度和高度
-$("#searchPanel").panel({width:webW-2});
-$("#tablePanel").panel({width:webW-2});
-var listTitle = "零售出库列表"; //单据标题
-var depotString = "|"; //店铺id列表
-var listType ="出库";//入库 出库
-var listSubType = "零售";//采购 销售等
-var payTypeTitle = "收款"; //付款 收款
-var organUrl ="/supplier/findBySelect_retail"; //组织数据接口地址
-var amountNum ="LSCK";//单据编号开头字符
-$(function(){
- //初始化系统基础信息
- initSystemData_UB();
- initSelectInfo_UB();
- initSystemData_depot();
- initSelectInfo_depot();
- initSystemData_person();
- initSelectInfo_person();
- initSystemData_account();
- initSelectInfo_account();
- initSupplier(); //供应商
- initSalesman(); //销售人员
- initOutItemList(); //初始化支出项目
- initMProperty(); //初始化商品属性
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
-});
-
-//初始化系统基础信息
-function initSystemData_UB(){
- $.ajax({
- type:"get",
- url: "/userBusiness/getBasicData",
- data: ({
- KeyId:kid,
- Type:"UserDepot"
- }),
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if (res && res.code === 200) {
- userBusinessList = res.data.userBusinessList;
- }
- else {
- userBusinessList = null;
- }
- }
- });
-
-}
-//初始化页面选项卡
-function initSelectInfo_UB(){
-
- if(userBusinessList !=null)
- {
- if(userBusinessList.length>0)
- {
- //用户对应的仓库列表 [1][2][3]...
- userdepot =userBusinessList[0].value;
- }
- }
-}
-
-
-//初始化系统基础信息
-function initSystemData_depot(){
- $.ajax({
- type:"get",
- url: "/depot/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200){
- depotList = res.data;
- } else {
- $.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error');
- return;
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_depot(){
- var options = "";
-
- if(depotList !=null)
- {
- options = "";
- for(var i = 0 ;i < depotList.length;i++)
- {
- var depot = depotList[i];
-
- if(userdepot!=null)
- {
- if(userdepot.indexOf("["+depot.id+"]")!=-1)
- {
- if(depot.isDefault){
- defDepotId = depot.id;
- }
- options += '';
- depotString = depotString + depot.id + ",";
- }
- }
- if(depot.type === 1){
- depotString = depotString + depot.id + ",";
- }
- }
- depotString = depotString.substring(1, depotString.length-1);
- $("#ProjectId").empty().append(options);
- $("#AllocationProjectId").empty().append(options);
- $("#searchProjectId").empty().append('').append(options);
- }
-}
-
-//初始化供应商、客户、散户信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onLoadSuccess: function(res) {
- var data = $(this).combobox('getData');
- for(var i = 0; i<= data.length; i++){
- if(data && data[i] && data[i].supplier === "非会员"){
- orgDefaultId = data[i].id;
- }
- }
- orgDefaultList = res;
- },
- onSelect: function(rec){
- var option = "";
- if(rec.supplier !== "非会员" && rec.advanceIn >0){
- option = '';
- option += '';
- }
- else {
- option += '';
- }
- $("#payType").empty().append(option);
- }
- });
-}
-
-//初始化销售人员
-function initSalesman(){
- $('#Salesman').combobox({
- url: "/person/getPersonByNumType?type=1",
- valueField:'id',
- textField:'name',
- multiple: true
- });
-}
-
-//初始化收入项目列表
-function initOutItemList(){
- $.ajax({
- type:"get",
- url: "/inOutItem/findBySelect?type=out",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res){
- if(res){
- outItemList = res;
- }
- },
- error:function(){
-
- }
- });
-}
-
-//初始化商品属性
-function initMProperty(){
- $.ajax({
- type: "get",
- url: "/materialProperty/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- name: ""
- }),
- currentPage: 1,
- pageSize: 100
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- var thisRows = res.data.page.rows;
- for (var i = 0; i < thisRows.length; i++) {
- if (thisRows[i].enabled) {
- mPropertyList += thisRows[i].nativename + ",";
- }
- }
- if (mPropertyList) {
- mPropertyList = mPropertyList.substring(0, mPropertyList.length - 1);
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化系统基础信息
-function initSystemData_person(){
- $.ajax({
- type:"get",
- url: "/person/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- personList = res.data.personList;
- }
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_person(){
- var options1 = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="仓管员")
- {
- options1 += '';
- }
- }
- $("#HandsPersonId").empty().append(options1);
- }
-}
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null){
- options = "";
- options += "";
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- if(account.isdefault) {
- defaultAccountId = account.id; //给账户赋值默认id
- }
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#depotHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- if(pageType === "skip") {
- var oldRowInfo = sessionStorage.getItem("rowInfo");
- editDepotHead(oldRowInfo); //自动弹出编辑框,带缓存数据
- }
- var hideType = undefined;
- var isHiddenStatus = true;
- if(payTypeTitle === "隐藏"){
- hideType = true; //隐藏当前列
- }
- var tableToolBar = [
- {
- id:'addDepotHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addDepotHead();
- }
- },
- {
- id:'deleteDepotHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteDepotHead();
- }
- }
- ];
- //如果允许的按钮列表中存在就显示,3-代表审核|反审核的权限
- if(btnEnableList && btnEnableList.indexOf(3)>-1){
- isHiddenStatus = false; //显示
- tableToolBar.push({
- id:'okDepotHead',
- text:'审核',
- iconCls:'icon-ok',
- handler:function() {
- setStatusFun();
- }
- },
- {
- id:'undoDepotHead',
- text:'反审核',
- iconCls:'icon-undo',
- handler:function() {
- setUnStatusFun();
- }
- });
- }
- else {
- isHiddenStatus = true; //隐藏
- }
- var isShowLastMoneyColumn = true; //是否显示优惠后金额和价税合计,true为隐藏,false为显示
- var isShowOrganNameColumn = false; //是否显示供应商、客户等信息,true为隐藏,false为显示
- var organNameTitle = "会员卡号"; //组织名称标题
- var opWidth = 90; //操作宽度
- var opTitle = ""; //跳转按钮的标题
- $('#tableData').datagrid({
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: true,
- //交替出现背景
- striped : true,
- pageSize: 10,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:opWidth,
- formatter:function(value, rec,index) {
- var str = '';
- var orgId = rec.organid? rec.organid:0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
- { title: '单据编号',field: 'number',width:135, formatter:function (value,rec) {
- if(rec.linknumber) {
- return value + "[转]";
- } else {
- return value;
- }
- }
- },
- { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
- if(value) {
- return value.replace(",",",");
- }
- }
- },
- { title: '单据日期',field: 'opertimeStr',width:130},
- { title: '操作员',field: 'operpersonname',width:60},
- { title: '金额合计',field: 'totalprice',width:60},
- { title: '含税合计',field: 'totaltaxlastmoney',hidden:isShowLastMoneyColumn,width:60,formatter:function(value,rec){
- return (rec.discountmoney + rec.discountlastmoney).toFixed(2);
- }
- },
- { title: '优惠后金额',field: 'discountlastmoney',hidden:isShowLastMoneyColumn,width:80},
- { title: payTypeTitle,field: 'changeamount',width:50,hidden:hideType},
- { title: '状态',field: 'status',hidden:isHiddenStatus, width:70,align:"center",formatter:function(value){
- if(value === "0") {
- return "未审核";
- } else if(value === "1") {
- return "已审核";
- } else if(value === "2") {
- }
- }
- }
- ]],
- toolbar:tableToolBar,
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//查找库存的方法
-function findStockNumById(depotId, mId, monthTime, body, input, ratio, type){
- var thisRatio = 1; //比例
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (rec) {
- if(rec && rec.code === 200 && rec.data && rec.data[0]) {
- var loadRatio = 1; //在单位输入框上面加载比例字段
- if(rec.data[0].unit) { //如果存在计量单位信息
- loadRatio = 1;
- }
- else{
- var unitName = rec.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- thisRatio = unitName.substring(unitName.indexOf(":")+1).replace(")","");
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- unitSetInput = rec.data[0].firstoutunit;
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = thisRatio;
- }
- }
- //查询库存
- $.ajax({
- type: "get",
- url: '/depotItem/findStockNumById',
- data:{
- projectId: depotId,
- materialId: mId
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if (res.data && res.data.page && res.data.page[0]) {
- var thisStock = res.data.page[0].thisSum;
- if (type == "select") { //选择下拉框的时候
- if (ratio != undefined && ratio != 1) {
- loadRatio = ratio;
- }
- }
- else if (type == "click") { //点击库存的时候
- if (ratio != undefined) {
- loadRatio = ratio;
- }
- }
- thisStock = (thisStock / loadRatio).toFixed(2);
- body.find("[field='Stock']").find(input).val(thisStock).attr("data-stock", res.data.page[0].thisSum); //加载库存数据
- }
- else {
- body.find("[field='Stock']").find(input).val(0).attr("data-stock", 0); //加载库存数据
- }
- body.find("[field='Stock']").find(input).prop("readonly", "readonly"); //设置库存数据为只读
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
- }
- },
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- }
- });
-}
-//优惠率、合计的统计方法
-function statisticsFun(body,UnitPrice,OperNumber,footer,taxRate){
- var TotalPrice = 0;
- var taxLastMoneyTotal = 0;
- //金额的合计
- body.find("[field='AllPrice']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + UnitPrice*OperNumber;
- footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); //金额的合计
- //价税合计的总计
- body.find("[field='TaxLastMoney']").each(function(){
- if($(this).find("div").text()!==""){
- taxLastMoneyTotal = taxLastMoneyTotal + (parseFloat($(this).find("div").text().toString())-0);
- }
- });
- taxLastMoneyTotal = taxLastMoneyTotal + (UnitPrice*OperNumber*(1+taxRate/100));
- footer.find("[field='TaxLastMoney']").find("div").text((taxLastMoneyTotal).toFixed(2)); //价税合计的页脚总计
- var discount = $("#Discount").val(); //优惠率
- var discountMoney = (taxLastMoneyTotal*discount/100).toFixed(2);
- $("#DiscountMoney").val(discountMoney);//优惠金额
- var discountLastMoney = (taxLastMoneyTotal*(1-discount/100)).toFixed(2)
- $("#DiscountLastMoney").val(discountLastMoney);//优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
-
- $("#ChangeAmount, #getAmount").val((TotalPrice).toFixed(2));
- $("#backAmount").val(0);
-}
-//初始化表格数据-商品列表-编辑状态
-function initTableData_material(type,TotalPrice){
- var body,footer,input; //定义表格和文本框
- var ratio = 1; //比例-品名专用
- var ratioDepot = 1; //比例-仓库用
- var monthTime = getNowFormatMonth();
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var depotHeadName = ""; //仓库名称
- var depotUrl = ""; //仓库接口地址
- var depotTextField = ""; //仓库下拉名称
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var anotherDepotUrl = ""; //对方仓库接口地址
- var anotherDepotTextField = "";
- depotHeadName = "仓库名称";
- depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- depotTextField = "depotName";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialData').datagrid({
- height:245,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: '商品类型',field: 'MType',editor:'validatebox',hidden:isShowMaterialTypeColumn,width:80},
- { title: depotHeadName, field: 'DepotId', editor: 'validatebox', width: 90,
- formatter: function (value, row, index) {
- return row.DepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: depotTextField,
- method: 'get',
- url: depotUrl,
- onSelect:function(rec){
- var depotId = rec.id;
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- if(mId){
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratioDepot, type);
- }
- }
- }
- }
- },
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialId',width:230,
- formatter:function(value,row,index){
- return row.MaterialName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'MaterialName',
- method:'get',
- url: "/material/findBySelect",
- panelWidth: 300, //下拉框的宽度
- //全面模糊匹配,过滤字段
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onBeforeLoad: function(param){
- param.mpList = mPropertyList; //商品属性
- },
- onSelect:function(rec){
- if(rec) {
- var mId = rec.Id;
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (res) {
- if(res && res.code === 200 && res.data && res.data[0]) {
- var retailPrice = res.data[0].retailprice-0; //零售价格
- var presetPriceOne = res.data[0].presetpriceone-0; //预计采购价
- var presetPriceTwo = res.data[0].presetpricetwo-0; //批发价
- var firstInUnit = res.data[0].firstinunit; //首选入库单位
- var firstOutUnit = res.data[0].firstoutunit; //首选出库单位
- var basicPresetPriceOne = ""; //多单位-入库-基础价格
- var basicPresetPriceTwo = ""; //多单位-出库-基础价格
- var retailPriceOne = ""; //多单位-入库-零售价格
- var otherPresetPriceOne = ""; //多单位-入库-其他价格
- var otherPresetPriceTwo = ""; //多单位-出库-其他价格
- var retailPriceTwo = ""; //多单位-出库-零售价格
- var basicUnit = ""; //基础单位
- var otherUnit = ""; //其他单位
- if(!res.data[0].unit){
- var ps = res.data[0].pricestrategy;
- var psObj = JSON.parse(ps);
- basicPresetPriceOne = psObj[0].basic.PresetPriceOne-0;
- basicPresetPriceTwo = psObj[0].basic.PresetPriceTwo-0;
- retailPriceOne = psObj[0].basic.RetailPrice-0;
- otherPresetPriceOne = psObj[1].other.PresetPriceOne-0;
- otherPresetPriceTwo = psObj[1].other.PresetPriceTwo-0;
- retailPriceTwo = psObj[1].other.RetailPrice-0;
- basicUnit = psObj[0].basic.Unit;
- otherUnit = psObj[1].other.Unit;
- }
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- if(res.data[0].unit){ //如果存在计量单位信息
- ratio = 1; //重置比例为1
- body.find("[field='Unit']").find(input).val(res.data[0].unit); //设置-计量单位信息
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- body.find("[field='Unit']").find(input).off("click"); //移除点击事件
- body.find("[field='Unit']").find(input).attr("data-ratio",ratio); //修改比例缓存信息
- }
- else {
- var unitName = res.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- var loadRatio = 1; //在单位输入框上面加载比例字段
- unitSetInput = res.data[0].firstoutunit; //给单位文本框赋值
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = ratio;
- }
- body.find("[field='Unit']").find(input).val(unitSetInput).attr("data-ratio", loadRatio); //设置-首选单位
-
- body.find("[field='Unit']").find(input).off("click").on("click",function(){
- if(basicUnit && otherUnit) {
- var self = this;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- " + basicUnit + "
";
- temp +="- " + otherUnit + "
";
- temp +="
";
- temp +="
";
- if($('.unit-list').length){
- $('.unit-list').remove(); //如果存在计量单位列表先移除
- }
- else {
- $(self).after(temp); //加载列表信息
- }
- //计量单位列表的单击事件
- $('.unit-list ul li').off("click").on("click",function(){
- var unit = $(this).text();
- var thisRatio = $(this).attr("data-ratio"); //获取比例
- $(self).val(unit).attr("data-ratio", thisRatio);
- $(self).keyup(); //模拟键盘操作
- $('.unit-list').remove(); //移除计量单位列表
- var stock = body.find("[field='Stock']").find(input).attr("data-stock"); //从缓存中取值
- var type = $(this).attr("data-type");
- var UnitPrice = 0;
- if(type === "basic"){
- UnitPrice = retailPriceOne;
- body.find("[field='Stock']").find(input).val(stock); //修改库存
- }
- else if(type === "other"){
- UnitPrice = retailPriceTwo;
- body.find("[field='Stock']").find(input).val((stock/ratio).toFixed(2)); //修改库存
- }
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //获取数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击空白处移除计量单位列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.unit-list').remove(); //移除计量单位列表
- });
- }
- });
- }
- var detailPrice = 0; //明细列表-单价
- if(res.data[0].unit) { //如果存在计量单位信息
- detailPrice = retailPrice;
- }
- else {
- if (firstOutUnit == basicUnit) {
- detailPrice = retailPriceOne;
- }
- else if (firstOutUnit == otherUnit) {
- detailPrice = retailPriceTwo;
- }
- }
- body.find("[field='OperNumber']").find(input).val(1); //数量初始化为1
- //单价和总价赋值
- if(!detailPrice) {
- detailPrice = 0;
- }
- body.find("[field='UnitPrice']").find(input).val(detailPrice);
- body.find("[field='AllPrice']").find(input).val(detailPrice);
- var taxRate = body.find("[field='TaxRate']").find(input).val()-0; //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((detailPrice*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,detailPrice,1,footer,taxRate);
-
- //查询库存信息
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- if(depotId) {
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, loadRatio, type);
- }
- }
- },
- error: function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- }
- });
- }
- }
- }
- }
- },
- { title: '库存',field: 'Stock',editor:'validatebox',width:70},
- { title: anotherDepotHeadName, field: 'AnotherDepotId',editor:'validatebox',hidden:isShowAnotherDepot,width:90,
- formatter: function (value, row, index) {
- return row.AnotherDepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: anotherDepotTextField,
- method: 'get',
- url: anotherDepotUrl
- }
- }
- },
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率(%)',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batchDel(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = 0;
- var TaxLastMoney = 0;
- var DiscountMoney = $("#DiscountMoney").val()-0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoney").val()-0; //优惠后金额
- if(type === "edit") {
- AllPrice = TotalPrice;
- TaxLastMoney = DiscountMoney + DiscountLastMoney;
- }
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": TaxLastMoney
- });
- data.footer = array;
- $("#materialData").datagrid('loadData',data);
- //如果是订单跳转到采购或销售
- if(pageType === "skip") {
- var skipList = $("#depotHeadFM .datagrid-body tr");
- //逐条自动点击每行数据
- skipList.each(function (i) {
- setTimeout(function () {
- skipList.eq(i).find("[field='Stock']").click();
- },(i+1)*1000);
- });
- }
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//初始化表格数据-商品列表-查看状态
-function initTableData_material_show(TotalPrice){
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var depotHeadName = ""; //仓库的列的标题
- depotHeadName = "仓库名称";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialDataShow').datagrid({
- height:245,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- onClickRow: onClickRow,
- columns:[[
- { title: '商品类型',field: 'MType',width:80, hidden:isShowMaterialTypeColumn},
- { title: depotHeadName,field: 'DepotName',editor:'validatebox',width:90},
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialName',width:230},
- { title: anotherDepotHeadName,field: 'AnotherDepotName',hidden:isShowAnotherDepot,width:90},
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validattebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = TotalPrice;
- var DiscountMoney = $("#DiscountMoneyShow").text() - 0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoneyShow").text() - 0; //优惠后金额
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": DiscountMoney + DiscountLastMoney
- });
- data.footer = array;
- $("#materialDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showDepotHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除单据信息
-function deleteDepotHead(depotHeadID, thisOrganId, totalPrice, status){
- if(status == "1" || status == "2") {
- $.messager.alert('删除提示','已审核和已转的单据不能删除!','warning');
- return;
- }
- $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
- if (r) {
- $.ajax({
- type:"post",
- // url: "/depotHead/" + depotHeadID + "/delete",
- url: "/depotHead/deleteDepotHeadAndDetail",
- dataType: "json",
- data:{
- id: depotHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
- return;
- }
- });
-
- //更新会员的预收款信息
- $.ajax({
- type:"post",
- url: "/supplier/updateAdvanceIn",
- dataType: "json",
- data:{
- supplierId: thisOrganId, //会员id
- advanceIn: totalPrice //删除时同时返还用户的预付款
- },
- success: function(res){
- if(res && res.code === 200) {
- //保存会员预收款成功
- }
- },
- error: function(){
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-}
-
-//订单转采购或销售
-function skipDepotHead(index, status){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- if(status == "0" || status == "2") {
- $.messager.alert('提示','未审核和已转的单据禁止操作!','warning');
- } else {
- sessionStorage.setItem("rowInfo", JSON.stringify(rowsdata)); //将单据信息存入缓存中
- }
-}
-
-//批量删除单据信息
-function batDeleteDepotHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条单据信息吗?',function(r)
- {
- if (r) {
- var ids = "";
- for (var i = 0; i < row.length; i++) {
- if (i == row.length - 1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- if (ids) {
- //批量更新会员的预收款信息
- for (var i = 0; i < row.length; i++) {
- $.ajax({
- type: "post",
- url: "/supplier/updateAdvanceIn",
- dataType: "json",
- data: {
- supplierId: row[i].organid, //会员id
- advanceIn: row[i].totalprice //删除时同时返还用户的预付款
- },
- success: function (res) {
- if (res && res.code === 200) {
- //保存会员预收款成功
- }
- },
- error: function () {
- $.messager.alert('提示', '保存信息异常,请稍后再试!', 'error');
- return;
- }
- });
- }
- //批量删除
- $.ajax({
- type: "post",
- // url: "/depotHead/batchDelete",
- url: "/depotHead/batchDeleteDepotHeadAndDetail",
- dataType: "json",
- async: false,
- data: ({
- ids: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除单据信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('删除提示','没有能删除的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量审核
-function setStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('审核确认','确定要审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: "1",
- depotHeadIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('审核提示', '审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('审核提示','审核信息异常,请稍后再试!','error');
- return;
- }
- });
- } else {
- $.messager.alert('审核提示','没有能审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量反审核
-function setUnStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('反审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('反审核确认','确定要反审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type: "post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async: false,
- data: ({
- status: "0",
- depotHeadIDs: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('反审核提示', '反审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('反审核提示', '反审核信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('反审核提示','没有能反审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//生成单据编号
-function buildNumber() {
- $.ajax({
- type: "get",
- url: "/depotHead/buildNumber",
- success:function(res){
- if(res && res.code === 200){
- var obj = res.data;
- var defaultNumber = obj.DefaultNumber;
- var newNumber = amountNum + defaultNumber;
- $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
- }
- },
- error:function(){
- $.messager.alert('提示','生成单据编号失败!','error');
- }
- });
-}
-
-//新增信息
-function addDepotHead(){
- $('#depotHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- buildNumber(); //生成单据编号
- //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为0
- $("#Discount").val(0);
- $("#DiscountMoney").val(0);
- $("#DiscountLastMoney").val(0);
- $("#ChangeAmount").val(0);
- $("#Debt").val(0);
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- var addTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgDepotHead = "";
- depotHeadID = 0;
- initTableData_material("add"); //商品列表
- reject(); //撤销下、刷新商品列表
- $("#addOrgan").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加供应商信息');
- $('#supplierFM').form('clear');
- });
-
- $("#addMember").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加会员信息');
- $('#supplierFM').form('clear');
- });
- $("#addCustomer").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加客户信息');
- $('#supplierFM').form('clear');
- });
- url = '/depotHead/addDepotHeadAndDetail';
-
- //零售单据修改收款时,自动计算找零
- $("#payType").val("现付");
- $("#OrganId").combobox("setValue", orgDefaultId); //自动默认选择非会员
- // 鼠标点下时清空选择项
- $("#OrganId").next().find("input").off("mousedown").on("mousedown",function(){
- $("#OrganId").combobox("setValue", "");
- });
- //当会员卡号长度超过10位后,自动点击下拉框,用于兼容刷卡器
- $("#OrganId").next().find("input").off("keyup").on("keyup",function(){
- var self = this;
- if($(this).val().length === 10){
- setTimeout(function(){
- $(".combo-panel .combobox-item-selected").click();
- //更新付款类型,加载会员的预付款的金额
- for(var i=0; i0){
- option = '';
- option += '';
- }
- else {
- option += '';
- }
- $("#payType").empty().append(option);
- }
- }
- },1000);
- }
- });
- var getAmount = $("#depotHeadFM .get-amount");
- var changeAmount = $("#depotHeadFM .change-amount");
- var backAmount = $("#depotHeadFM .back-amount");
- getAmount.val(0); changeAmount.val(0); backAmount.val(0); //时间初始化
- getAmount.off("keyup").on("keyup",function() {
- if(changeAmount.val()){
- backAmount.val((getAmount.val()-changeAmount.val()).toFixed(2));
- }
- });
-}
-
-//编辑信息
-function editDepotHead(index, status){
- if(status == "1" || status == "2") {
- $.messager.alert('编辑提示','已审核和已转的单据不能编辑!','warning');
- return;
- }
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata ='';
- if(Number(index).toString()=='NaN'){
- rowsdata=$.parseJSON(index);
- }else{
- rowsdata=$("#tableData").datagrid("getRows")[index];
- }
- $("#ProjectId").focus().val(rowsdata.projectid);
- var ProjectId=rowsdata.projectid;
- if(ProjectId!='') {
- initSystemData_person(ProjectId);
- initSelectInfo_person();
- }
- var TotalPrice = rowsdata.totalprice; //合计金额
- if(pageType === "skip") { //从订单跳转过来
- buildNumber(); //生成单据编号
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- $("#LinkNumber").val(rowsdata.number); //关联订单号
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- $("#DiscountLastMoney").val(TotalPrice); //优惠后金额
- $("#ChangeAmount").val(TotalPrice).attr("data-changeamount", TotalPrice);
- } else {
- $("#Number").val(rowsdata.number).attr("data-defaultNumber",rowsdata.number);
- $("#OperTime").val(rowsdata.opertimeStr);
- $("#LinkNumber").val(rowsdata.linknumber==undefined?"":rowsdata.linknumber); //关联订单号
- $("#AccountId").val(rowsdata.accountid); //账户Id
- $("#DiscountLastMoney").val(rowsdata.discountlastmoney==undefined?"0.00":rowsdata.discountlastmoney); //优惠后金额
- $("#ChangeAmount").val(rowsdata.changeamount).attr("data-changeamount", rowsdata.changeamount);
- }
- $('#OrganId').combobox('setValue', rowsdata.organid==undefined?'':rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#Remark").val(rowsdata.remark);
- $("#Discount").val(rowsdata.discount==undefined?"0":rowsdata.discount);
- $("#DiscountMoney").val(rowsdata.discountmoney==undefined?"0.00":rowsdata.discountmoney);
- $("#Debt").val(Number((rowsdata.discountlastmoney==undefined?'0.00':rowsdata.discountlastmoney-rowsdata.changeamount)).toFixed(2));
- $("#AccountDay").val(rowsdata.accountday==undefined?"":rowsdata.accountday); //结算天数
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于扣预付款
- $("#AllocationProjectId").val(rowsdata.allocationprojectid);
- oldNumber = rowsdata.number; //记录编辑前的单据编号
- oldId = rowsdata.id; //记录单据Id
- var editTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- depotHeadID = rowsdata.id;
-
- var option = "";
- if(rowsdata.paytype == "预付款"){
- option = '';
- option += '';
- }
- else {
- option += '';
- }
- $("#payType").empty().append(option);
-
-
- //采购入库、销售出库的多账户加载
- if(rowsdata.accountidlist!=undefined && rowsdata.accountmoneylist!=undefined){
- $("#AccountId").val("many"); //下拉框选中多账户
- var accountArr = rowsdata.accountidlist.split(",");
- var accountMoneyArr = rowsdata.accountmoneylist.split(",");
- accountMoneyArr = changeListFmtPlus(accountMoneyArr) //将数组单个金额中的数值转为正数
-
- var manyAccountMoney = 0; //多账户合计-零售
- for (var j = 0; j < accountArr.length; j++) {
- if (accountList != null) {
- for (var i = 0; i < accountList.length; i++) {
- var account = accountList[i];
- if (accountArr[j] == account.id) {
- manyAccountMoney += accountMoneyArr[j] - 0; //多账户合计-零售
- }
- }
- }
- }
- $("#getAmount").val(manyAccountMoney); //收款金额、付款金额
- var changeAmount = $("#ChangeAmount").val()-0;
- $("#backAmount").val((manyAccountMoney-changeAmount).toFixed(2)); //找零
-
- $("#AccountId").attr("data-accountArr", JSON.stringify(accountArr)).attr("data-accountMoneyArr", JSON.stringify(accountMoneyArr)); //json数据存储
- $(".many-account-ico").show(); //显示多账户的ico图标
- }
-
- //采购入库、销售出库的费用数据加载
- if(rowsdata.othermoneylist &&rowsdata.othermoneyitem){
- $("#OtherMoney").val(rowsdata.othermoney==undefined?"0":rowsdata.othermoney); //采购费用、销售费用
- var itemArr = rowsdata.othermoneylist.split(",");
- var itemMoneyArr = rowsdata.othermoneyitem.split(",");
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
-
- initTableData_material("edit",TotalPrice); //商品列表
- reject(); //撤销下、刷新商品列表
- if(pageType === "skip") {
- url = '/depotHead/addDepotHeadAndDetail'; //如果是从订单跳转过来,则此处为新增的接口
- //jshjshjsh
- $("#depotHeadFM .datagrid-body").find("[field='DepotId']").click();
- } else {
- url = '/depotHead/updateDepotHeadAndDetail?id=' + rowsdata.id; //更新接口
- }
-}
-
-//查看信息
-function showDepotHead(index){
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var manyAccountMoney = 0; //多账户合计-零售
- $("#ProjectIdShow").text(rowsdata.projectName);
- $("#NumberShow").text(rowsdata.number);
- $("#OperTimeShow").text(rowsdata.opertimeStr);
- $('#OrganIdShow').text(rowsdata.organName==undefined?'':rowsdata.organName);
- $("#HandsPersonIdShow").text(rowsdata.handsPersonName);
- if(rowsdata.accountName && rowsdata.accountName!=undefined){
- $("#AccountIdShow").text(rowsdata.accountName); //结算账户
- } else {
- var accountArr = (rowsdata.accountidlist==undefined?"":rowsdata.accountidlist).split(","); //账户id列表
- var accountMoneyArr =(rowsdata.accountmoneylist==undefined?"":rowsdata.accountmoneylist).split(","); //账户金额列表
- var accountIdShow = "";
- for(var j =0;j 查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- depotHeadID = rowsdata.id;
- initTableData_material_show(TotalPrice); //商品列表-查看状态
-
- //零售单据展示数据
- var changeAccount = $("#depotHeadDlgShow .change-amount-show").text() -0;
- if(manyAccountMoney!==0){
- $("#depotHeadDlgShow .get-amount-show").text((manyAccountMoney).toFixed(2));
- $("#depotHeadDlgShow .back-amount-show").text((manyAccountMoney -changeAccount).toFixed(2));
- }
- else {
- $("#depotHeadDlgShow .get-amount-show").text((changeAccount).toFixed(2));
- $("#depotHeadDlgShow .back-amount-show").text(0);
- }
-}
-
-//绑定操作事件
-function bindEvent(){
- showDepotHeadDetails(1,initPageSize); //初始化时自动查询
- //搜索处理
- $("#searchBtn").off("click").on("click",function(){
- showDepotHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh',
- {
- pageNumber:1,
- pageSize:initPageSize
- });
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- //$("#searchProjectId").val("");
- $("#searchState").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //检查单据编号是否存在
- function checkDepotHeadNumber() {
- var thisNumber = $.trim($("#Number").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(thisNumber.length > 0 &&( oldNumber.length ==0 || thisNumber != oldNumber))
- {
- $.ajax({
- type:"get",
- url: "/depotHead/checkIsNumberExist",
- dataType: "json",
- async : false,
- data: ({
- DepotHeadID : oldId,
- Number : thisNumber
- }),
- success: function (tipInfo)
- {
- flag = tipInfo;
- if(tipInfo)
- {
- $.messager.alert('提示','抱歉,该单据编号已经存在','warning');
- return;
- }
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','检查单据编号是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
- //保存信息
- /**
- * 2019-01-25
- * 我对这个方法的实现结果存在严重怀疑,决定重构
- * 有如下疑点:
- * 1、保存完主表,返回结果后,再发起请求去操作子表,如何保证事务的一致性(业务数据一致性)
- * 2、保存完主表后,再通过selectmax的方式去获取主表主键id完全就是看人品的不可靠的思路
- * 修改计划:
- * 2019-01-25修改零售出库相关操作
- * 修改方式,重写url,将主从表操作合并
- *
- *
- * **/
- $("#saveDepotHead").off("click").on("click",function(){
- if(!$('#depotHeadFM').form('validate')){
- return;
- }
- else {
- //如果初始编号被修改了,就要判断单据编号是否存在
- if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
- //调用查询单据编号是否重名的方法
- if(checkDepotHeadNumber()){
- return;
- }
- }
- if(!$('#AccountId').val()){
- $.messager.alert('提示','请选择收款账户!','warning');
- return;
- }
- if($("#backAmount").val()-0 <0){
- $.messager.alert('提示','找零金额不能小于0!','warning');
- return;
- }
- if($("#AccountId").val() == "many" && $("#backAmount").val()-0 >0) {
- $.messager.alert('提示', '选择多账户时的找零金额不能大于0!', 'warning');
- return;
- }
- if (editIndex != undefined) {
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- //进行明细的校验
- if(depotHeadID ==0) {
- //新增模式下
- if (!CheckData("add")) {
- return;
- }
- }
- else {
- //编辑模式下
- if (!CheckData("edit")) {
- return;
- }
- }
- var OrganId = null, ProjectId = null,AllocationProjectId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val())-0;
- var TotalPrice = $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text();
- if($('#OrganId').length){
- OrganId = $('#OrganId').combobox('getValue');
- }
- var accountMoneyList = $("#AccountId").attr("data-accountmoneyarr"); //账户金额列表-多账户
- var accountMoneyArr;
- if(accountMoneyList) {
- accountMoneyList = accountMoneyList.replace("[","").replace("]","").toString();
- var reg=new RegExp("\"","g"); //创建正则RegExp对象
- accountMoneyList = accountMoneyList.replace(reg,""); //替换所有的双引号
- accountMoneyArr = accountMoneyList.split(","); //转为数组
- }
- //零售时候,可以从会员预付款中扣款
- var thisPayType = "现付";
- if($("#payType").val() ==="预付款") {
- thisPayType = "预付款";
- }
- var SalesmanStr = "";
- var getAccountID = $.trim($("#AccountId").val());
- if($("#AccountId").val() === "many"){ //多账户
- getAccountID = null;
- }
- var infoStr=JSON.stringify({
- Type: listType,
- SubType: listSubType,
- ProjectId: ProjectId,
- AllocationProjectId: AllocationProjectId,
- DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
- Number: $.trim($("#Number").val()),
- LinkNumber: $.trim($("#LinkNumber").val()),
- OperTime: $("#OperTime").val(),
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Salesman: SalesmanStr, //销售人员
- AccountId: getAccountID,
- ChangeAmount: ChangeAmount, //付款/收款
- TotalPrice: TotalPrice, //合计
- PayType: thisPayType, //现付/预付款
- Remark: $.trim($("#Remark").val()),
- AccountIdList: $("#AccountId").attr("data-accountarr"), //账户列表-多账户
- AccountMoneyList: accountMoneyArr ? JSON.stringify(accountMoneyArr) : "", //账户金额列表-多账户
- Discount: $.trim($("#Discount").val()),
- DiscountMoney: $.trim($("#DiscountMoney").val()),
- DiscountLastMoney: $.trim($("#DiscountLastMoney").val()),
- OtherMoney: $.trim($("#OtherMoney").val()), //采购费用、销售费用
- OtherMoneyList: $("#OtherMoney").attr("data-itemarr"), //支出项目列表-涉及费用
- OtherMoneyItem: $("#OtherMoney").attr("data-itemmoneyarr"), //支出项目金额列表-涉及费用
- AccountDay: $("#AccountDay").val() //结算天数
- });
- /**
- * 零售出库,单独操作
- * */
- if(url.indexOf("/depotHead/addDepotHeadAndDetail")>=0){
- addDepotHeadAndDetail(url,infoStr);
- return;
- }else if(url.indexOf("/depotHead/updateDepotHeadAndDetail")>=0){
- updateDepotHeadAndDetail(url,infoStr,preTotalPrice);
- return;
- }
- }
- });
-
- //打印单据
- $("#printDepotHeadShow").off("click").on("click",function(){
- var tableString = $("#depotHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event){
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="State"||obj.id=="Number"))
- {
- $("#saveDepotHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber"||obj.id=="searchMaterial"))
- {
- $("#searchBtn").click();
- }
- });
-
- //优惠率输入框事件
- $("#Discount").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountNum = $(this).val();
- var discountMoney = (discountNum/100*totalPrice).toFixed(2);
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#DiscountMoney").val(discountMoney); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //优惠金额输入框事件
- $("#DiscountMoney").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountMoney = $(this).val();
- var discount = (discountMoney/totalPrice).toFixed(2)*100;
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#Discount").val(discount); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //付款、收款输入框事件
- $("#ChangeAmount").off("keyup").on("keyup",function(){
- var discountLastMoney = $("#DiscountLastMoney").val();
- var changeAmount = $(this).val();
- var debtMoney = (discountLastMoney - changeAmount).toFixed(2);
- $("#Debt").val(debtMoney); //本次欠款
- });
-
- //多账户结算窗口弹出事件
- function depotHeadAccountDlgFun(){
- $('#depotHeadAccountDlg').dialog('open').dialog('setTitle','
多账户结算');
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").remove(); //先移除输入栏目
- $("#accountMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#depotHeadAccountDlg .tabs-tmp .account-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#depotHeadAccountDlg .tabs-tmp tbody").html();
- var accountDlgHead = $("#depotHeadAccountDlg .account-head-tmp");
- accountDlgHead.after(contentTmp);
- }
-
- //获取账户信息
- function accountDlgFun() {
- var options = "";
- if(accountList !=null){
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- }
- $(".account-id-dlg").empty().append("").append(options);
- }
- }
- accountDlgFun(); //获取账户信息
- $("#depotHeadAccountDlg .tabs-tmp").hide(); //隐藏模板
-
- //账户金额输入框事件-多账户
- $("#depotHeadAccountDlg .account-dlg .account-money-dlg").off("keyup").on("keyup",function(){
- var totalAccoutNum = 0;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var eachAccountMoney = $(this).find(".account-money-dlg").val()-0;
- totalAccoutNum += eachAccountMoney;
- });
- $("#accountMoneyTotalDlg").text(totalAccoutNum);
- });
-
- //结算多账户列表的切换事件
- $("#depotHeadAccountDlg .account-dlg .account-id-dlg").off("change").on("change",function(){
- var selectAccount = $(this).children('option:selected').text();
- if(selectAccount === ""){
- var thisMoneyDom = $(this).closest(".account-content-tmp").find(".account-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text() - 0;
- $("#accountMoneyTotalDlg").text(accountMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //账户为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveDepotHeadAccountDlg").off("click").on("click", function(){
- //完成多账户的json数据存储
- var accountArr = []; //账户id数组
- var accountMoneyArr = []; //账户金额数组
- var errorIndex = -1;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var thisAccId = $(this).find(".account-id-dlg").val();
- var thisAccMoney = $(this).find(".account-money-dlg").val();
- if(!thisAccId && thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && !thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && thisAccMoney) {
- accountArr.push(thisAccId);
- accountMoneyArr.push(thisAccMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var discountLastMoneyNum =$("#DiscountLastMoney").val()-0; //优惠后金额
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text()-0; //本次付款或者收款
- if(accountMoneyTotal===0){
- $.messager.alert('错误提示',"请填写金额后保存",'warning');
- return;
- }
- if(accountArr.length && accountMoneyArr.length) {
- $("#AccountId").attr("data-accountArr",JSON.stringify(accountArr)).attr("data-accountMoneyArr",JSON.stringify(accountMoneyArr)); //json数据存储
- }
- $("#getAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
- var backAmount = $("#getAmount").val() - $("#ChangeAmount").val();
- $("#backAmount").val((backAmount - 0).toFixed(2)); //计算找零金额
- $("#Debt").val((discountLastMoneyNum-accountMoneyTotal).toFixed(2)); //本次欠款
- $("#depotHeadAccountDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#AccountId").attr("data-accountArr")){
- $("#depotHeadAccountDlg").dialog('close');
- }
- else {
- $("#depotHeadAccountDlg").dialog('close');
- $("#AccountId").val("").removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").prop("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- }
- //多账户-取消按钮
- $("#cancelDepotHeadAccountDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //多账户-右上角的关闭按钮
- $("#depotHeadAccountDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
- }
- //点击多账户,弹出输入框
- $("#AccountId").off("change").on("change",function(){
- var selectText = $(this).children('option:selected').text();
- if(selectText === "多账户"){
- $("#ChangeAmount").prop("readonly","readonly");
- depotHeadAccountDlgFun();
- $(".many-account-ico").show(); //显示多账户小图标
- }
- else{
- $(this).removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").prop("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- });
-
- //结算账户-多账户小图标-点击事件
- $(".many-account-ico").off("click").on("click",function(){
- depotHeadAccountDlgFun();
- //给弹窗赋值-多账户数据
- var accountArr = $("#AccountId").attr("data-accountArr");
- accountArr = JSON.parse(accountArr);
- var accountMoneyArr = $("#AccountId").attr("data-accountMoneyArr");
- accountMoneyArr = JSON.parse(accountMoneyArr);
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".account-id-dlg").val(accountArr[index]);
- $(this).find(".account-money-dlg").val(accountMoneyArr[index]);
- });
- $("#accountMoneyTotalDlg").text($("#getAmount").val());
- });
-
- //点击采购费用、销售费用的事件
- $(".other-money-ico").off("click").on("click",function(){
- $('#otherMoneyDlg').dialog('open').dialog('setTitle','
'+ listSubType +'费用');
- $("#otherMoneyDlg .money-dlg .money-content-tmp").remove(); //先移除输入栏目
- $("#otherMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#otherMoneyDlg .tabs-tmp .money-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#otherMoneyDlg .tabs-tmp tbody").html();
- var moneyDlgHead = $("#otherMoneyDlg .money-head-tmp");
- moneyDlgHead.after(contentTmp);
- }
-
- //获取支出项目信息
- function moneyDlgFun() {
- var options = "";
- if(outItemList !=null){
- for(var i = 0 ;i < outItemList.length;i++) {
- var money = outItemList[i];
- options += '';
- }
- $(".money-id-dlg").empty().append("").append(options);
- }
- }
- moneyDlgFun(); //获取支出项目信息
- $("#otherMoneyDlg .tabs-tmp").hide(); //隐藏模板
-
- //支出项目的金额输入框事件
- $("#otherMoneyDlg .money-dlg .other-money-dlg").off("keyup").on("keyup",function(){
- var totalMoneyNum = 0;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var eachOtherMoney = $(this).find(".other-money-dlg").val()-0;
- totalMoneyNum += eachOtherMoney;
- });
- $("#otherMoneyTotalDlg").text(totalMoneyNum);
- });
-
- //支出项目列表的切换事件
- $("#otherMoneyDlg .money-dlg .money-id-dlg").off("change").on("change",function(){
- var selectItem = $(this).children('option:selected').text();
- if(selectItem === ""){
- var thisMoneyDom = $(this).closest(".money-content-tmp").find(".other-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text() - 0;
- $("#otherMoneyTotalDlg").text(otherMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //支出项目为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveOtherMoneyDlg").off("click").on("click", function(){
- //完成支出项目的json数据存储
- var itemArr = []; //支出项目id数组
- var itemMoneyArr = []; //支出项目金额数组
- var errorIndex = -1;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var thisId = $(this).find(".money-id-dlg").val();
- var thisMoney = $(this).find(".other-money-dlg").val();
- if(!thisId && thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && !thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && thisMoney) {
- itemArr.push(thisId);
- itemMoneyArr.push(thisMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text()-0; //合计金额
- if(otherMoneyTotal === 0){ //0的时候清空缓存数据
- $("#OtherMoney").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr");
- }
- if(itemArr.length && itemMoneyArr.length) {
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
- $("#OtherMoney").val(otherMoneyTotal); //给采购费用、销售费用赋值
- $("#otherMoneyDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#OtherMoney").attr("data-itemArr")){
- $("#otherMoneyDlg").dialog('close');
- }
- else {
- $("#otherMoneyDlg").dialog('close');
- $("#OtherMoney").val("").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr"); //将下拉置空并把缓存参数清空
- }
- }
- //费用-取消按钮
- $("#cancelOtherMoneyDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //费用-右上角的关闭按钮
- $("#otherMoneyDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
-
- //给弹窗赋值-采购费用、销售费用数据
- var itemArr = $("#OtherMoney").attr("data-itemArr");
- itemArr = JSON.parse(itemArr);
- var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr");
- itemMoneyArr = JSON.parse(itemMoneyArr);
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".money-id-dlg").val(itemArr[index]);
- if(itemMoneyArr[index]!="undefined"){
- $(this).find(".other-money-dlg").val(itemMoneyArr[index]);
- }
- });
- $("#otherMoneyTotalDlg").text($("#OtherMoney").val());
- });
-
- var supplierType = "会员";
- //检查单位名称是否存在 ++ 重名无法提示问题需要跟进
- function checkSupplierName() {
- var supplierName = $.trim($("#supplier").val());
- var orgSupplier = "";
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(supplierName.length > 0 &&( orgSupplier.length ==0 || supplierName != orgSupplier))
- {
- $.ajax({
- type:"get",
- url: "/supplier/checkIsNameExist",
- dataType: "json",
- async : false,
- data: ({
- id : 0,
- name : supplierName
- }),
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data && res.data.status) {
- flag = res.data.status;
- if (flag) {
- $.messager.alert('提示', '单位名称已经存在', 'info');
- return;
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('提示','检查单位名称是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
-
- //保存供应商信息
- $("#saveSupplier").off("click").on("click",function() {
- if(validateForm("supplierFM")) {
- return;
- }
- if(checkSupplierName()){
- return;
- }
- var reg = /^([0-9])+$/;
- var phonenum = $.trim($("#phonenum").val());
- if(phonenum.length>0 && !reg.test(phonenum))
- {
- $.messager.alert('提示','电话号码只能是数字','info');
- $("#phonenum").val("").focus();
- return;
- }
- var beginNeedGet = $.trim($("#BeginNeedGet").val());
- var beginNeedPay = $.trim($("#BeginNeedPay").val());
- if(beginNeedGet && beginNeedPay) {
- $.messager.alert('提示','期初应收和期初应付不能同时输入','info');
- return;
- }
- var url = '/supplier/add';
- var supObj = $("#supplierFM").serializeObject();
- supObj.type = supplierType;
- supObj.enabled = 1;
- $.ajax({
- url: url,
- type:"post",
- dataType: "json",
- data:{
- info: JSON.stringify(supObj)
- },
- success: function(res) {
- if (res) {
- $('#supplierDlg').dialog('close');
- initSupplier(); //刷新供应商
- }
- }
- });
- });
-}
-
-function showDepotHeadDetails(pageNo,pageSize){
- var materialParam = $.trim($("#searchMaterial").val());
- var beginTime = $.trim($("#searchBeginTime").val());
- var endTime = $.trim($("#searchEndTime").val());
- if(beginTime) {
- beginTime = beginTime + ' 00:00:00';
- }
- if(endTime) {
- endTime = endTime + ' 23:59:59';
- }
- $.ajax({
- type: "get",
- url: "/depotHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- subType: listSubType,
- state: $.trim($("#searchState").val()),
- number: $.trim($("#searchNumber").val()),
- beginTime: beginTime,
- endTime: endTime,
- materialParam: materialParam,
- depotIds: depotString
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- return;
- }
- });
-}
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#depotHeadFM .datagrid-body");
- var footer =$("#depotHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
- //点击商品下拉框,自动加载数量、单价、金额
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //点击库存文本框,字段计算库存
- body.find("[field='Stock']").find(input).off("click").on("click",function(){
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- var monthTime = getNowFormatMonth();
- if(depotId && mId){
- var ratio = body.find("[field='Unit']").find(input).attr("data-ratio");
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //在新增的时候,这个ratio有值;在编辑的时候,这个ratio为undefined
- var type = "click"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratio, type);
- }
- else{
- body.find("[field='Stock']").find(input).val(0).attr("data-stock",0); //加载库存数据
- }
- });
- //修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计
- body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber =$(this).val()-0; //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
-
- });
- //修改单价,自动计算金额和合计
- body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice =$(this).val()-0; //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击单价,自动提示参考价格列表
- body.find("[field='UnitPrice']").find(input).off("click").on("click",function(){
- var self = this;
- var mValue = body.find("[field='MaterialId'] .combo-value").attr("value"); //获取选中的商品id
- if(!mValue) {
- return;
- }
- else {
- return;
- }
- });
- //修改含税单价,自动计算单价、金额、税额、价税合计和合计
- body.find("[field='TaxUnitPrice']").find(input).off("keyup").on("keyup",function(){
- var TaxUnitPrice =$(this).val()-0; //含税单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var UnitPrice = TaxUnitPrice/(1+taxRate/100); //计算单价
- body.find("[field='UnitPrice']").find(input).val((UnitPrice).toFixed(2)); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改金额,自动计算单价、税额、价税合计和合计
- body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var AllPrice =$(this).val()-0; //金额
- var UnitPrice = (AllPrice/OperNumber).toFixed(2);
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税率,自动计算含税单价、税额、价税合计和合计
- body.find("[field='TaxRate']").find(input).off("keyup").on("keyup",function(){
- var taxRate =$(this).val()-0; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税额,自动计算税率、含税单价、价税合计和合计
- body.find("[field='TaxMoney']").find(input).off("keyup").on("keyup",function(){
- var taxMoney =$(this).val()-0; //税额
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = taxMoney/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改价税合计,自动计算税率、含税单价、税额和合计
- body.find("[field='TaxLastMoney']").find(input).off("keyup").on("keyup",function(){
- var taxLastMoney =$(this).val()-0; //价税合计
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = (taxLastMoney-AllPrice)/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
-
- //加载税率
- if(thisTaxRate) {
- body.find("[field='TaxRate']").find(input).val(thisTaxRate);
- }
- else {
- body.find("[field='TaxRate']").find(input).val(0); //默认为0
- }
-
- //在商品类型加载 组装件、普通子件
- var mType = body.find("[field='MType']");
- var rowListLength = mType.find(input).closest(".datagrid-row").attr("datagrid-row-index");
- var mTypeValue = "组合件";
- if(rowListLength > 0){
- mTypeValue = "普通子件";
- }
- },500);
-}
-
-//结束编辑
-function endEditing() {
- if (editIndex == undefined) { return true }
- if ($('#materialData').datagrid('validateRow', editIndex)) {
- //仓库信息
- var edDepot = $('#materialData').datagrid('getEditor', {index:editIndex,field:'DepotId'});
- var DepotName = $(edDepot.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName;
- //商品信息
- var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'});
- var MaterialName = $(edMaterial.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName;
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#materialData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append(){
- if (endEditing()) {
- $('#materialData').datagrid('appendRow', {DepotId:defDepotId});
- editIndex = $('#materialData').datagrid('getRows').length - 1;
- $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function batchDel(){
- /**
- * 重写一下删除的逻辑
- * 获取所有选中行,直接从列表中移除
- * 点击保存时,将需要后台删除的数据提交到服务器
- * **/
- /**
- * create by: qiankunpingtai
- * create time: 2019/3/20 16:26
- * description:
- * 这个地方比较坑的,花了一个多小时才搞明白为什么
- * 1、删除之前必须先调用endEditing结束编辑
- * 2、如果只是调用endEditing结束编辑那么正在编辑行的被选中状态会被去掉
- * 所以要在调用endEditing先获取选中的行
- */
- //如果编辑的行一开始是选中状态,结束编辑后仍然是选中状态
- var row = $('#materialData').datagrid('getChecked');
- if (endEditing()) {
- if (row.length == 0) {
- $.messager.alert('删除提示', '没有记录被选中!', 'info');
- return;
- }
- if (row.length > 0) {
- $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条单据信息吗?', function (r) {
- if (r) {
- for (var i = 0; i < row.length; i++) {
- $('#materialData').datagrid('deleteRow', $('#materialData').datagrid("getRowIndex", row[i]));
- }
- }
- });
- }
- }
-}
-function removeit(){
- if (editIndex == undefined) { return }
- $('#materialData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#materialData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData(type) {
- var change = $('#materialData').datagrid('getChanges').length;
- if(type =="add" && !change) {
- $.messager.alert('提示','请输入明细信息!','warning');
- return false;
- }
- var row = $('#materialData').datagrid('getRows');
- if(!row.length){
- $.messager.alert('提示',"请输入明细信息!",'info');
- return false;
- }
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if (row[i].DepotId == "" || row[i].MaterialId == "" || row[i].OperNumber == "" || row[i].UnitPrice === "" || row[i].AllPrice === "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-
-
-/**
- * 新增单据主表及单据子表
- * */
-function addDepotHeadAndDetail(url,infoStr){
- var inserted = null;
- if(pageType === "skip") {
- inserted = $("#materialData").datagrid('getChanges', "updated");
- } else {
- inserted = $("#materialData").datagrid('getChanges', "inserted");
- }
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated)
- }),
- success: function (tipInfo){
-
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
-
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
-
-
- });
-}
-/**
- * 修改单据主表及单据子表
- * */
-function updateDepotHeadAndDetail(url,infoStr,preTotalPrice){
- var inserted = $("#materialData").datagrid('getChanges', "inserted");
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- id:url.substring(url.lastIndexOf("?id=")+4,url.length),
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- preTotalPrice:preTotalPrice
- }),
- success: function (tipInfo){
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
- if (endEditing()) {
- $('#materialData').datagrid('acceptChanges');
- }
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-
-
-
diff --git a/erp_web/js/pages/materials/sale_back_list.js b/erp_web/js/pages/materials/sale_back_list.js
deleted file mode 100644
index fe87a20c..00000000
--- a/erp_web/js/pages/materials/sale_back_list.js
+++ /dev/null
@@ -1,2465 +0,0 @@
-//初始化界面
-var defDepotId = null;
-var kid = sessionStorage.getItem("userId");
-var pageType = getUrlParam('t'); //获取页面类型传值
-var depotList = null;
-var depotID = null;
-var supplierList = null;
-var supplierID = null;
-var personList = null;
-var personID = null;
-var ProjectSearch=null;
-var userBusinessList=null;
-var userdepot=null;
-var url;
-var depotHeadID = 0;
-var preTotalPrice = 0; //前一次加载的金额
-var orgDepotHead = "";
-var editIndex = undefined;
-/**默认编号有意义吗,不如空着吧*/
-var orgDefaultId=''; //单位默认编号
-var orgDefaultList; //存储查询出来的会员列表
-var accountList; //账户列表
-var outItemList; //支出项目列表
-var thisTaxRate = 0; //当前税率,选择供应商或者客户的时候设置
-var oldNumber = ""; //编辑前的单据编号
-var oldId = 0; //编辑前的单据Id
-var otherColumns = true; //明细中的‘别名’列是否显示
-var btnEnableList = getBtnStr(); //获取按钮的权限
-var mPropertyList = ""; //商品属性列表
-var defaultAccountId = 0; //默认账户id
-//改变宽度和高度
-$("#searchPanel").panel({width:webW-2});
-$("#tablePanel").panel({width:webW-2});
-var listTitle = "销售退货列表"; //单据标题
-var depotString = "|"; //店铺id列表
-var listType = "入库";//入库 出库
-var listSubType = "销售退货";//采购 销售等
-var payTypeTitle = "付款"; //付款 收款
-var organUrl ="/supplier/findBySelect_cus?UBType=UserCustomer&UBKeyId=" + kid; //组织数据接口地址
-var amountNum ="XSTH";//单据编号开头字符
-$(function(){
- //初始化系统基础信息
- initSystemData_UB();
- initSelectInfo_UB();
- initSystemData_depot();
- initSelectInfo_depot();
- initSystemData_person();
- initSelectInfo_person();
- initSystemData_account();
- initSelectInfo_account();
- initSupplier(); //供应商
- initSalesman(); //销售人员
- initOutItemList(); //初始化支出项目
- initMProperty(); //初始化商品属性
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
-});
-
-//初始化系统基础信息
-function initSystemData_UB(){
- $.ajax({
- type:"get",
- url: "/userBusiness/getBasicData",
- data: ({
- KeyId:kid,
- Type:"UserDepot"
- }),
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if (res && res.code === 200) {
- userBusinessList = res.data.userBusinessList;
- }
- else {
- userBusinessList = null;
- }
- }
- });
-
-}
-//初始化页面选项卡
-function initSelectInfo_UB(){
-
- if(userBusinessList !=null)
- {
- if(userBusinessList.length>0)
- {
- //用户对应的仓库列表 [1][2][3]...
- userdepot =userBusinessList[0].value;
- }
- }
-}
-
-
-//初始化系统基础信息
-function initSystemData_depot(){
- $.ajax({
- type:"get",
- url: "/depot/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200){
- depotList = res.data;
- } else {
- $.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error');
- return;
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_depot(){
- var options = "";
-
- if(depotList !=null)
- {
- options = "";
- for(var i = 0 ;i < depotList.length;i++)
- {
- var depot = depotList[i];
-
- if(userdepot!=null)
- {
- if(userdepot.indexOf("["+depot.id+"]")!=-1)
- {
- if(depot.isDefault){
- defDepotId = depot.id;
- }
- options += '';
- depotString = depotString + depot.id + ",";
- }
- }
- if(depot.type === 1){
- depotString = depotString + depot.id + ",";
- }
- }
- depotString = depotString.substring(1, depotString.length-1);
- $("#ProjectId").empty().append(options);
- $("#AllocationProjectId").empty().append(options);
- $("#searchProjectId").empty().append('').append(options);
- }
-}
-
-//初始化供应商、客户、散户信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onLoadSuccess: function(res) {
- var data = $(this).combobox('getData');
- for(var i = 0; i<= data.length; i++){
- if(data && data[i] && data[i].supplier === "非会员"){
- orgDefaultId = data[i].id;
- }
- }
- },
- onSelect: function(rec){
- $.ajax({
- type:"get",
- url: "/supplier/findById",
- data: {
- supplierId: rec.id
- },
- dataType: "json",
- success: function (res){
- if(res && res.code === 200) {
- if(res.data && res.data[0]){
- thisTaxRate = res.data[0].taxRate; //设置当前的税率
- }
- }
- },
- error:function(){
-
- }
- });
- }
- });
-}
-
-//初始化销售人员
-function initSalesman(){
- $('#Salesman').combobox({
- url: "/person/getPersonByNumType?type=1",
- valueField:'id',
- textField:'name',
- multiple: true
- });
-}
-
-//初始化收入项目列表
-function initOutItemList(){
- $.ajax({
- type:"get",
- url: "/inOutItem/findBySelect?type=out",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res){
- if(res){
- outItemList = res;
- }
- },
- error:function(){
-
- }
- });
-}
-
-//初始化商品属性
-function initMProperty(){
- $.ajax({
- type: "get",
- url: "/materialProperty/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- name: ""
- }),
- currentPage: 1,
- pageSize: 100
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- var thisRows = res.data.page.rows;
- for (var i = 0; i < thisRows.length; i++) {
- if (thisRows[i].enabled) {
- mPropertyList += thisRows[i].nativename + ",";
- }
- }
- if (mPropertyList) {
- mPropertyList = mPropertyList.substring(0, mPropertyList.length - 1);
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化系统基础信息
-function initSystemData_person(){
- $.ajax({
- type:"get",
- url: "/person/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- personList = res.data.personList;
- }
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_person(){
- var options1 = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="仓管员")
- {
- options1 += '';
- }
- }
- $("#HandsPersonId").empty().append(options1);
- }
-}
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null){
- options = "";
- options += "";
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- if(account.isdefault) {
- defaultAccountId = account.id; //给账户赋值默认id
- }
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#depotHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- if(pageType === "skip") {
- var oldRowInfo = sessionStorage.getItem("rowInfo");
- editDepotHead(oldRowInfo); //自动弹出编辑框,带缓存数据
- }
- var hideType = undefined;
- var isHiddenStatus = true;
- if(payTypeTitle === "隐藏"){
- hideType = true; //隐藏当前列
- }
- var tableToolBar = [
- {
- id:'addDepotHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addDepotHead();
- }
- },
- {
- id:'deleteDepotHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteDepotHead();
- }
- }
- ];
- //如果允许的按钮列表中存在就显示,3-代表审核|反审核的权限
- if(btnEnableList && btnEnableList.indexOf(3)>-1){
- isHiddenStatus = false; //显示
- tableToolBar.push({
- id:'okDepotHead',
- text:'审核',
- iconCls:'icon-ok',
- handler:function() {
- setStatusFun();
- }
- },
- {
- id:'undoDepotHead',
- text:'反审核',
- iconCls:'icon-undo',
- handler:function() {
- setUnStatusFun();
- }
- });
- }
- else {
- isHiddenStatus = true; //隐藏
- }
- var isShowLastMoneyColumn = false; //是否显示优惠后金额和价税合计,true为隐藏,false为显示
- var isShowOrganNameColumn = false; //是否显示供应商、客户等信息,true为隐藏,false为显示
- var organNameTitle = "客户名称"; //组织名称标题
- var opWidth = 90; //操作宽度
- var isShowSkip = false; //是否显示跳转按钮
- var opTitle = ""; //跳转按钮的标题
- $('#tableData').datagrid({
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: true,
- //交替出现背景
- striped : true,
- pageSize: 10,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:opWidth,
- formatter:function(value, rec,index) {
- var str = '';
- var orgId = rec.organid? rec.organid:0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
- { title: '单据编号',field: 'number',width:135, formatter:function (value,rec) {
- if(rec.linknumber) {
- return value + "[转]";
- } else {
- return value;
- }
- }
- },
- { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
- if(value) {
- return value.replace(",",",");
- }
- }
- },
- { title: '单据日期',field: 'opertimeStr',width:130},
- { title: '操作员',field: 'operpersonname',width:60},
- { title: '金额合计',field: 'totalprice',width:60},
- { title: '含税合计',field: 'totaltaxlastmoney',hidden:isShowLastMoneyColumn,width:60,formatter:function(value,rec){
- return (rec.discountmoney + rec.discountlastmoney).toFixed(2);
- }
- },
- { title: '优惠后金额',field: 'discountlastmoney',hidden:isShowLastMoneyColumn,width:80},
- { title: payTypeTitle,field: 'changeamount',width:50,hidden:hideType},
- { title: '状态',field: 'status',hidden:isHiddenStatus, width:70,align:"center",formatter:function(value){
- if(value === "0") {
- return "未审核";
- } else if(value === "1") {
- return "已审核";
- } else if(value === "2") {
- }
- }
- }
- ]],
- toolbar:tableToolBar,
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//查找库存的方法
-function findStockNumById(depotId, mId, monthTime, body, input, ratio, type){
- var thisRatio = 1; //比例
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (rec) {
- if(rec && rec.code === 200 && rec.data && rec.data[0]) {
- var loadRatio = 1; //在单位输入框上面加载比例字段
- if(rec.data[0].unit) { //如果存在计量单位信息
- loadRatio = 1;
- }
- else{
- var unitName = rec.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- thisRatio = unitName.substring(unitName.indexOf(":")+1).replace(")","");
- unitName = unitName.substring(0, unitName.indexOf("("));
- unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
-
- var unitSetInput =""; //单位
- unitSetInput = rec.data[0].firstoutunit;
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = thisRatio;
- }
- }
- //查询库存
- $.ajax({
- type: "get",
- url: '/depotItem/findStockNumById',
- data:{
- projectId: depotId,
- materialId: mId
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if (res.data && res.data.page && res.data.page[0]) {
- var thisStock = res.data.page[0].thisSum;
- if (type == "select") { //选择下拉框的时候
- if (ratio != undefined && ratio != 1) {
- loadRatio = ratio;
- }
- }
- else if (type == "click") { //点击库存的时候
- if (ratio != undefined) {
- loadRatio = ratio;
- }
- }
- thisStock = (thisStock / loadRatio).toFixed(2);
- body.find("[field='Stock']").find(input).val(thisStock).attr("data-stock", res.data.page[0].thisSum); //加载库存数据
- }
- else {
- body.find("[field='Stock']").find(input).val(0).attr("data-stock", 0); //加载库存数据
- }
- body.find("[field='Stock']").find(input).prop("readonly", "readonly"); //设置库存数据为只读
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
- }
- },
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- }
- });
-}
-//优惠率、合计的统计方法
-function statisticsFun(body,UnitPrice,OperNumber,footer,taxRate){
- var TotalPrice = 0;
- var taxLastMoneyTotal = 0;
- //金额的合计
- body.find("[field='AllPrice']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + UnitPrice*OperNumber;
- footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); //金额的合计
- //价税合计的总计
- body.find("[field='TaxLastMoney']").each(function(){
- if($(this).find("div").text()!==""){
- taxLastMoneyTotal = taxLastMoneyTotal + (parseFloat($(this).find("div").text().toString())-0);
- }
- });
- taxLastMoneyTotal = taxLastMoneyTotal + (UnitPrice*OperNumber*(1+taxRate/100));
- footer.find("[field='TaxLastMoney']").find("div").text((taxLastMoneyTotal).toFixed(2)); //价税合计的页脚总计
- var discount = $("#Discount").val(); //优惠率
- var discountMoney = (taxLastMoneyTotal*discount/100).toFixed(2);
- $("#DiscountMoney").val(discountMoney);//优惠金额
- var discountLastMoney = (taxLastMoneyTotal*(1-discount/100)).toFixed(2)
- $("#DiscountLastMoney").val(discountLastMoney);//优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
-}
-//初始化表格数据-商品列表-编辑状态
-function initTableData_material(type,TotalPrice){
- var body,footer,input; //定义表格和文本框
- var ratio = 1; //比例-品名专用
- var ratioDepot = 1; //比例-仓库用
- var monthTime = getNowFormatMonth();
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var depotHeadName = ""; //仓库名称
- var depotUrl = ""; //仓库接口地址
- var depotTextField = ""; //仓库下拉名称
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var anotherDepotUrl = ""; //对方仓库接口地址
- var anotherDepotTextField = "";
- depotHeadName = "仓库名称";
- depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- depotTextField = "depotName";
- var isShowTaxColumn = false; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialData').datagrid({
- height:245,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: '商品类型',field: 'MType',editor:'validatebox',hidden:isShowMaterialTypeColumn,width:80},
- { title: depotHeadName, field: 'DepotId', editor: 'validatebox', width: 90,
- formatter: function (value, row, index) {
- return row.DepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: depotTextField,
- method: 'get',
- url: depotUrl,
- onSelect:function(rec){
- var depotId = rec.id;
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- if(mId){
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratioDepot, type);
- }
- }
- }
- }
- },
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialId',width:230,
- formatter:function(value,row,index){
- return row.MaterialName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'MaterialName',
- method:'get',
- url: "/material/findBySelect",
- panelWidth: 300, //下拉框的宽度
- //全面模糊匹配,过滤字段
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onBeforeLoad: function(param){
- param.mpList = mPropertyList; //商品属性
- },
- onSelect:function(rec){
- if(rec) {
- var mId = rec.Id;
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (res) {
- if(res && res.code === 200 && res.data && res.data[0]) {
- var retailPrice = res.data[0].retailprice-0; //零售价格
- var presetPriceOne = res.data[0].presetpriceone-0; //预计采购价
- var presetPriceTwo = res.data[0].presetpricetwo-0; //批发价
- var firstInUnit = res.data[0].firstinunit; //首选入库单位
- var firstOutUnit = res.data[0].firstoutunit; //首选出库单位
- var basicPresetPriceOne = ""; //多单位-入库-基础价格
- var basicPresetPriceTwo = ""; //多单位-出库-基础价格
- var retailPriceOne = ""; //多单位-入库-零售价格
- var otherPresetPriceOne = ""; //多单位-入库-其他价格
- var otherPresetPriceTwo = ""; //多单位-出库-其他价格
- var retailPriceTwo = ""; //多单位-出库-零售价格
- var basicUnit = ""; //基础单位
- var otherUnit = ""; //其他单位
- if(!res.data[0].unit){
- var ps = res.data[0].pricestrategy;
- var psObj = JSON.parse(ps);
- basicPresetPriceOne = psObj[0].basic.PresetPriceOne-0;
- basicPresetPriceTwo = psObj[0].basic.PresetPriceTwo-0;
- retailPriceOne = psObj[0].basic.RetailPrice-0;
- otherPresetPriceOne = psObj[1].other.PresetPriceOne-0;
- otherPresetPriceTwo = psObj[1].other.PresetPriceTwo-0;
- retailPriceTwo = psObj[1].other.RetailPrice-0;
- basicUnit = psObj[0].basic.Unit;
- otherUnit = psObj[1].other.Unit;
- }
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- if(res.data[0].unit){ //如果存在计量单位信息
- ratio = 1; //重置比例为1
- body.find("[field='Unit']").find(input).val(res.data[0].unit); //设置-计量单位信息
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- body.find("[field='Unit']").find(input).off("click"); //移除点击事件
- body.find("[field='Unit']").find(input).attr("data-ratio",ratio); //修改比例缓存信息
- }
- else {
- var unitName = res.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
-
- var unitSetInput =""; //单位
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- var loadRatio = 1; //在单位输入框上面加载比例字段
- unitSetInput = res.data[0].firstoutunit; //给单位文本框赋值
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = ratio;
- }
- body.find("[field='Unit']").find(input).val(unitSetInput).attr("data-ratio", loadRatio); //设置-首选单位
-
- body.find("[field='Unit']").find(input).off("click").on("click",function(){
- if(basicUnit && otherUnit) {
- var self = this;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- " + basicUnit + "
";
- temp +="- " + otherUnit + "
";
- temp +="
";
- temp +="
";
- if($('.unit-list').length){
- $('.unit-list').remove(); //如果存在计量单位列表先移除
- }
- else {
- $(self).after(temp); //加载列表信息
- }
- //计量单位列表的单击事件
- $('.unit-list ul li').off("click").on("click",function(){
- var unit = $(this).text();
- var thisRatio = $(this).attr("data-ratio"); //获取比例
- $(self).val(unit).attr("data-ratio", thisRatio);
- $(self).keyup(); //模拟键盘操作
- $('.unit-list').remove(); //移除计量单位列表
- var stock = body.find("[field='Stock']").find(input).attr("data-stock"); //从缓存中取值
- var type = $(this).attr("data-type");
- var UnitPrice = 0;
- if(type === "basic"){
- UnitPrice = basicPresetPriceOne;
- body.find("[field='Stock']").find(input).val(stock); //修改库存
- }
- else if(type === "other"){
- UnitPrice = otherPresetPriceOne;
- body.find("[field='Stock']").find(input).val((stock/ratio).toFixed(2)); //修改库存
- }
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //获取数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击空白处移除计量单位列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.unit-list').remove(); //移除计量单位列表
- });
- }
- });
- }
- var detailPrice = 0; //明细列表-单价
- if(res.data[0].unit) { //如果存在计量单位信息
- detailPrice = presetPriceOne;
- }
- else {
- if (firstInUnit == basicUnit) {
- detailPrice = basicPresetPriceOne;
- }
- else if (firstInUnit == otherUnit) {
- detailPrice = otherPresetPriceOne;
- }
- }
- body.find("[field='OperNumber']").find(input).val(1); //数量初始化为1
- //单价和总价赋值
- if(!detailPrice) {
- detailPrice = 0;
- }
- body.find("[field='UnitPrice']").find(input).val(detailPrice);
- body.find("[field='AllPrice']").find(input).val(detailPrice);
- var taxRate = body.find("[field='TaxRate']").find(input).val()-0; //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((detailPrice*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,detailPrice,1,footer,taxRate);
-
- //查询库存信息
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- if(depotId) {
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, loadRatio, type);
- }
- }
- },
- error: function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- }
- });
- }
- }
- }
- }
- },
- { title: '库存',field: 'Stock',editor:'validatebox',width:70},
- { title: anotherDepotHeadName, field: 'AnotherDepotId',editor:'validatebox',hidden:isShowAnotherDepot,width:90,
- formatter: function (value, row, index) {
- return row.AnotherDepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: anotherDepotTextField,
- method: 'get',
- url: anotherDepotUrl
- }
- }
- },
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率(%)',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batchDel(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = 0;
- var TaxLastMoney = 0;
- var DiscountMoney = $("#DiscountMoney").val()-0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoney").val()-0; //优惠后金额
- if(type === "edit") {
- AllPrice = TotalPrice;
- TaxLastMoney = DiscountMoney + DiscountLastMoney;
- }
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": TaxLastMoney
- });
- data.footer = array;
- $("#materialData").datagrid('loadData',data);
- //如果是订单跳转到采购或销售
- if(pageType === "skip") {
- var skipList = $("#depotHeadFM .datagrid-body tr");
- //逐条自动点击每行数据
- skipList.each(function (i) {
- setTimeout(function () {
- skipList.eq(i).find("[field='Stock']").click();
- },(i+1)*1000);
- });
- }
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//初始化表格数据-商品列表-查看状态
-function initTableData_material_show(TotalPrice){
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var depotHeadName = ""; //仓库的列的标题
- depotHeadName = "仓库名称";
- var isShowTaxColumn = false; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialDataShow').datagrid({
- height:245,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- onClickRow: onClickRow,
- columns:[[
- { title: '商品类型',field: 'MType',width:80, hidden:isShowMaterialTypeColumn},
- { title: depotHeadName,field: 'DepotName',editor:'validatebox',width:90},
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialName',width:230},
- { title: anotherDepotHeadName,field: 'AnotherDepotName',hidden:isShowAnotherDepot,width:90},
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validattebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = TotalPrice;
- var DiscountMoney = $("#DiscountMoneyShow").text() - 0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoneyShow").text() - 0; //优惠后金额
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": DiscountMoney + DiscountLastMoney
- });
- data.footer = array;
- $("#materialDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showDepotHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除单据信息
-function deleteDepotHead(depotHeadID, thisOrganId, totalPrice, status){
- if(status == "1" || status == "2") {
- $.messager.alert('删除提示','已审核和已转的单据不能删除!','warning');
- return;
- }
- $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
- if (r) {
- $.ajax({
- type:"post",
- // url: "/depotHead/" + depotHeadID + "/delete",
- url: "/depotHead/deleteDepotHeadAndDetail",
- dataType: "json",
- data:{
- id: depotHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
- return;
- }
- });
-
- }
- });
-}
-
-//订单转采购或销售
-function skipDepotHead(index, status){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- if(status == "0" || status == "2") {
- $.messager.alert('提示','未审核和已转的单据禁止操作!','warning');
- } else {
- sessionStorage.setItem("rowInfo", JSON.stringify(rowsdata)); //将单据信息存入缓存中
- }
-}
-
-//批量删除单据信息
-function batDeleteDepotHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条单据信息吗?',function(r)
- {
- if (r) {
- var ids = "";
- for (var i = 0; i < row.length; i++) {
- if (i == row.length - 1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- if (ids) {
- //批量删除
- $.ajax({
- type: "post",
- // url: "/depotHead/batchDelete",
- url: "/depotHead/batchDeleteDepotHeadAndDetail",
- dataType: "json",
- async: false,
- data: ({
- ids: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除单据信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('删除提示','没有能删除的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量审核
-function setStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('审核确认','确定要审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: "1",
- depotHeadIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('审核提示', '审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('审核提示','审核信息异常,请稍后再试!','error');
- return;
- }
- });
- } else {
- $.messager.alert('审核提示','没有能审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量反审核
-function setUnStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('反审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('反审核确认','确定要反审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type: "post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async: false,
- data: ({
- status: "0",
- depotHeadIDs: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('反审核提示', '反审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('反审核提示', '反审核信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('反审核提示','没有能反审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//生成单据编号
-function buildNumber() {
- $.ajax({
- type: "get",
- url: "/depotHead/buildNumber",
- success:function(res){
- if(res && res.code === 200){
- var obj = res.data;
- var defaultNumber = obj.DefaultNumber;
- var newNumber = amountNum + defaultNumber;
- $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
- }
- },
- error:function(){
- $.messager.alert('提示','生成单据编号失败!','error');
- }
- });
-}
-
-//新增信息
-function addDepotHead(){
- $('#depotHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- buildNumber(); //生成单据编号
- //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为0
- $("#Discount").val(0);
- $("#DiscountMoney").val(0);
- $("#DiscountLastMoney").val(0);
- $("#ChangeAmount").val(0);
- $("#Debt").val(0);
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- var addTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgDepotHead = "";
- depotHeadID = 0;
- initTableData_material("add"); //商品列表
- reject(); //撤销下、刷新商品列表
- $("#addOrgan").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加供应商信息');
- $('#supplierFM').form('clear');
- });
-
- $("#addMember").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加会员信息');
- $('#supplierFM').form('clear');
- });
- $("#addCustomer").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加客户信息');
- $('#supplierFM').form('clear');
- });
- url = '/depotHead/addDepotHeadAndDetail';
-}
-
-//编辑信息
-function editDepotHead(index, status){
- if(status == "1" || status == "2") {
- $.messager.alert('编辑提示','已审核和已转的单据不能编辑!','warning');
- return;
- }
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata ='';
- if(Number(index).toString()=='NaN'){
- rowsdata=$.parseJSON(index);
- }else{
- rowsdata=$("#tableData").datagrid("getRows")[index];
- }
- $("#ProjectId").focus().val(rowsdata.projectid);
- var ProjectId=rowsdata.projectid;
- if(ProjectId!='') {
- initSystemData_person(ProjectId);
- initSelectInfo_person();
- }
- var TotalPrice = rowsdata.totalprice; //合计金额
- if(pageType === "skip") { //从订单跳转过来
- buildNumber(); //生成单据编号
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- $("#LinkNumber").val(rowsdata.number); //关联订单号
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- $("#DiscountLastMoney").val(TotalPrice); //优惠后金额
- $("#ChangeAmount").val(TotalPrice).attr("data-changeamount", TotalPrice);
- } else {
- $("#Number").val(rowsdata.number).attr("data-defaultNumber",rowsdata.number);
- $("#OperTime").val(rowsdata.opertimeStr);
- $("#LinkNumber").val(rowsdata.linknumber==undefined?"":rowsdata.linknumber); //关联订单号
- $("#AccountId").val(rowsdata.accountid); //账户Id
- $("#DiscountLastMoney").val(rowsdata.discountlastmoney==undefined?"0.00":rowsdata.discountlastmoney); //优惠后金额
- $("#ChangeAmount").val(rowsdata.changeamount).attr("data-changeamount", rowsdata.changeamount);
- }
- $('#OrganId').combobox('setValue', rowsdata.organid==undefined?'':rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#Remark").val(rowsdata.remark);
- $("#Discount").val(rowsdata.discount==undefined?"0":rowsdata.discount);
- $("#DiscountMoney").val(rowsdata.discountmoney==undefined?"0.00":rowsdata.discountmoney);
- $("#Debt").val(Number((rowsdata.discountlastmoney==undefined?'0.00':rowsdata.discountlastmoney-rowsdata.changeamount)).toFixed(2));
- $("#AccountDay").val(rowsdata.accountday==undefined?"":rowsdata.accountday); //结算天数
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于扣预付款
- $("#AllocationProjectId").val(rowsdata.allocationprojectid);
- oldNumber = rowsdata.number; //记录编辑前的单据编号
- oldId = rowsdata.id; //记录单据Id
- var editTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- depotHeadID = rowsdata.id;
-
-
- if(rowsdata.salesman){
- var arr = rowsdata.salesman.split(",");
- var salesmanArray = [];
- for(var i=0;i",""));
- }
- }
- $("#Salesman").combobox('setValues', salesmanArray);
- }
-
- //采购入库、销售出库的多账户加载
- if(rowsdata.accountidlist!=undefined && rowsdata.accountmoneylist!=undefined){
- $("#AccountId").val("many"); //下拉框选中多账户
- var accountArr = rowsdata.accountidlist.split(",");
- var accountMoneyArr = rowsdata.accountmoneylist.split(",");
- accountMoneyArr = changeListFmtPlus(accountMoneyArr) //将数组单个金额中的数值转为正数
-
- $("#AccountId").attr("data-accountArr", JSON.stringify(accountArr)).attr("data-accountMoneyArr", JSON.stringify(accountMoneyArr)); //json数据存储
- $(".many-account-ico").show(); //显示多账户的ico图标
- }
-
- //采购入库、销售出库的费用数据加载
- if(rowsdata.othermoneylist &&rowsdata.othermoneyitem){
- $("#OtherMoney").val(rowsdata.othermoney==undefined?"0":rowsdata.othermoney); //采购费用、销售费用
- var itemArr = rowsdata.othermoneylist.split(",");
- var itemMoneyArr = rowsdata.othermoneyitem.split(",");
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
-
- initTableData_material("edit",TotalPrice); //商品列表
- reject(); //撤销下、刷新商品列表
- if(pageType === "skip") {
- url = '/depotHead/addDepotHeadAndDetail'; //如果是从订单跳转过来,则此处为新增的接口
- //jshjshjsh
- $("#depotHeadFM .datagrid-body").find("[field='DepotId']").click();
- } else {
- url = '/depotHead/updateDepotHeadAndDetail?id=' + rowsdata.id; //更新接口
- }
-}
-
-//查看信息
-function showDepotHead(index){
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var manyAccountMoney = 0; //多账户合计-零售
- $("#ProjectIdShow").text(rowsdata.projectName);
- $("#NumberShow").text(rowsdata.number);
- $("#OperTimeShow").text(rowsdata.opertimeStr);
- $('#OrganIdShow').text(rowsdata.organName==undefined?'':rowsdata.organName);
- $("#HandsPersonIdShow").text(rowsdata.handsPersonName);
- if(rowsdata.accountName && rowsdata.accountName!=undefined){
- $("#AccountIdShow").text(rowsdata.accountName); //结算账户
- } else {
- var accountArr = (rowsdata.accountidlist==undefined?"":rowsdata.accountidlist).split(","); //账户id列表
- var accountMoneyArr =(rowsdata.accountmoneylist==undefined?"":rowsdata.accountmoneylist).split(","); //账户金额列表
- var accountIdShow = "";
- for(var j =0;j 查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- depotHeadID = rowsdata.id;
- initTableData_material_show(TotalPrice); //商品列表-查看状态
-
- if(rowsdata.salesman){
- var arr = rowsdata.salesman.split(",");
- var salesmanStr = "";
- for(var i=0;i","");
- }
- else {
- salesmanStr += arr[i].replace("<","").replace(">","") + ",";
- }
- }
- }
- $.ajax({
- type: "get",
- url: "/person/getPersonByIds",
- data: {
- personIDs: salesmanStr
- },
- success:function(res){
- if(res && res.code === 200){
- if(res.data) {
- $("#SalesmanShow").text(res.data.names); //销售人员列表
- }
- }
- },
- error:function(){
-
- }
- });
- }
-}
-
-//绑定操作事件
-function bindEvent(){
- showDepotHeadDetails(1,initPageSize); //初始化时自动查询
- //搜索处理
- $("#searchBtn").off("click").on("click",function(){
- showDepotHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh',
- {
- pageNumber:1,
- pageSize:initPageSize
- });
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- //$("#searchProjectId").val("");
- $("#searchState").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //检查单据编号是否存在
- function checkDepotHeadNumber() {
- var thisNumber = $.trim($("#Number").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(thisNumber.length > 0 &&( oldNumber.length ==0 || thisNumber != oldNumber))
- {
- $.ajax({
- type:"get",
- url: "/depotHead/checkIsNumberExist",
- dataType: "json",
- async : false,
- data: ({
- DepotHeadID : oldId,
- Number : thisNumber
- }),
- success: function (tipInfo)
- {
- flag = tipInfo;
- if(tipInfo)
- {
- $.messager.alert('提示','抱歉,该单据编号已经存在','warning');
- return;
- }
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','检查单据编号是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
- //保存信息
- /**
- * 2019-01-25
- * 我对这个方法的实现结果存在严重怀疑,决定重构
- * 有如下疑点:
- * 1、保存完主表,返回结果后,再发起请求去操作子表,如何保证事务的一致性(业务数据一致性)
- * 2、保存完主表后,再通过selectmax的方式去获取主表主键id完全就是看人品的不可靠的思路
- * 修改计划:
- * 2019-01-25修改零售出库相关操作
- * 修改方式,重写url,将主从表操作合并
- *
- *
- * **/
- $("#saveDepotHead").off("click").on("click",function(){
- if(!$('#depotHeadFM').form('validate')){
- return;
- }
- else {
- //如果初始编号被修改了,就要判断单据编号是否存在
- if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
- //调用查询单据编号是否重名的方法
- if(checkDepotHeadNumber()){
- return;
- }
- }
- //输入框提示
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择退货单位!','warning');
- return;
- }
- if(!$('#AccountId').val()){
- $.messager.alert('提示','请选择付款账户!','warning');
- return;
- }
- if (editIndex != undefined) {
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- //进行明细的校验
- if(depotHeadID ==0) {
- //新增模式下
- if (!CheckData("add")) {
- return;
- }
- }
- else {
- //编辑模式下
- if (!CheckData("edit")) {
- return;
- }
- }
- var OrganId = null, ProjectId = null,AllocationProjectId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val())-0;
- var TotalPrice = $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text();
- if($('#OrganId').length){
- OrganId = $('#OrganId').combobox('getValue');
- }
- var accountMoneyList = $("#AccountId").attr("data-accountmoneyarr"); //账户金额列表-多账户
- var accountMoneyArr;
- if(accountMoneyList) {
- accountMoneyList = accountMoneyList.replace("[","").replace("]","").toString();
- var reg=new RegExp("\"","g"); //创建正则RegExp对象
- accountMoneyList = accountMoneyList.replace(reg,""); //替换所有的双引号
- accountMoneyArr = accountMoneyList.split(","); //转为数组
- }
- //付款为负数
- ChangeAmount = 0 - ChangeAmount;
- TotalPrice = 0 - TotalPrice;
- if(accountMoneyArr) {
- accountMoneyArr = changeListFmtMinus(accountMoneyArr); //将数组单个金额中的数值转为负数
- }
- //零售时候,可以从会员预付款中扣款
- var thisPayType = "现付";
- var SalesmanStr = "";
- var Salesman = $('#Salesman').combobox('getValues').toString(); //销售人员
- if(Salesman) {
- var SalesmanArray = Salesman.split(",");
- for (var i = 0; i < SalesmanArray.length; i++) {
- if (i === SalesmanArray.length - 1) {
- SalesmanStr += "<" + SalesmanArray[i] + ">";
- }
- else {
- SalesmanStr += "<" + SalesmanArray[i] + ">,";
- }
- }
- }
- var getAccountID = $.trim($("#AccountId").val());
- if($("#AccountId").val() === "many"){ //多账户
- getAccountID = null;
- }
- var infoStr=JSON.stringify({
- Type: listType,
- SubType: listSubType,
- ProjectId: ProjectId,
- AllocationProjectId: AllocationProjectId,
- DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
- Number: $.trim($("#Number").val()),
- LinkNumber: $.trim($("#LinkNumber").val()),
- OperTime: $("#OperTime").val(),
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Salesman: SalesmanStr, //销售人员
- AccountId: getAccountID,
- ChangeAmount: ChangeAmount, //付款/收款
- TotalPrice: TotalPrice, //合计
- PayType: thisPayType, //现付/预付款
- Remark: $.trim($("#Remark").val()),
- AccountIdList: $("#AccountId").attr("data-accountarr"), //账户列表-多账户
- AccountMoneyList: accountMoneyArr ? JSON.stringify(accountMoneyArr) : "", //账户金额列表-多账户
- Discount: $.trim($("#Discount").val()),
- DiscountMoney: $.trim($("#DiscountMoney").val()),
- DiscountLastMoney: $.trim($("#DiscountLastMoney").val()),
- OtherMoney: $.trim($("#OtherMoney").val()), //采购费用、销售费用
- OtherMoneyList: $("#OtherMoney").attr("data-itemarr"), //支出项目列表-涉及费用
- OtherMoneyItem: $("#OtherMoney").attr("data-itemmoneyarr"), //支出项目金额列表-涉及费用
- AccountDay: $("#AccountDay").val() //结算天数
- });
- /**
- * 零售出库,单独操作
- * */
- if(url.indexOf("/depotHead/addDepotHeadAndDetail")>=0){
- addDepotHeadAndDetail(url,infoStr);
- return;
- }else if(url.indexOf("/depotHead/updateDepotHeadAndDetail")>=0){
- updateDepotHeadAndDetail(url,infoStr,preTotalPrice);
- return;
- }
- }
- });
-
- //打印单据
- $("#printDepotHeadShow").off("click").on("click",function(){
- var tableString = $("#depotHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event){
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="State"||obj.id=="Number"))
- {
- $("#saveDepotHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber"||obj.id=="searchMaterial"))
- {
- $("#searchBtn").click();
- }
- });
-
- //优惠率输入框事件
- $("#Discount").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountNum = $(this).val();
- var discountMoney = (discountNum/100*totalPrice).toFixed(2);
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#DiscountMoney").val(discountMoney); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //优惠金额输入框事件
- $("#DiscountMoney").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountMoney = $(this).val();
- var discount = (discountMoney/totalPrice).toFixed(2)*100;
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#Discount").val(discount); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //付款、收款输入框事件
- $("#ChangeAmount").off("keyup").on("keyup",function(){
- var discountLastMoney = $("#DiscountLastMoney").val();
- var changeAmount = $(this).val();
- var debtMoney = (discountLastMoney - changeAmount).toFixed(2);
- $("#Debt").val(debtMoney); //本次欠款
- });
-
- //多账户结算窗口弹出事件
- function depotHeadAccountDlgFun(){
- $('#depotHeadAccountDlg').dialog('open').dialog('setTitle','
多账户结算');
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").remove(); //先移除输入栏目
- $("#accountMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#depotHeadAccountDlg .tabs-tmp .account-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#depotHeadAccountDlg .tabs-tmp tbody").html();
- var accountDlgHead = $("#depotHeadAccountDlg .account-head-tmp");
- accountDlgHead.after(contentTmp);
- }
-
- //获取账户信息
- function accountDlgFun() {
- var options = "";
- if(accountList !=null){
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- }
- $(".account-id-dlg").empty().append("").append(options);
- }
- }
- accountDlgFun(); //获取账户信息
- $("#depotHeadAccountDlg .tabs-tmp").hide(); //隐藏模板
-
- //账户金额输入框事件-多账户
- $("#depotHeadAccountDlg .account-dlg .account-money-dlg").off("keyup").on("keyup",function(){
- var totalAccoutNum = 0;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var eachAccountMoney = $(this).find(".account-money-dlg").val()-0;
- totalAccoutNum += eachAccountMoney;
- });
- $("#accountMoneyTotalDlg").text(totalAccoutNum);
- });
-
- //结算多账户列表的切换事件
- $("#depotHeadAccountDlg .account-dlg .account-id-dlg").off("change").on("change",function(){
- var selectAccount = $(this).children('option:selected').text();
- if(selectAccount === ""){
- var thisMoneyDom = $(this).closest(".account-content-tmp").find(".account-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text() - 0;
- $("#accountMoneyTotalDlg").text(accountMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //账户为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveDepotHeadAccountDlg").off("click").on("click", function(){
- //完成多账户的json数据存储
- var accountArr = []; //账户id数组
- var accountMoneyArr = []; //账户金额数组
- var errorIndex = -1;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var thisAccId = $(this).find(".account-id-dlg").val();
- var thisAccMoney = $(this).find(".account-money-dlg").val();
- if(!thisAccId && thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && !thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && thisAccMoney) {
- accountArr.push(thisAccId);
- accountMoneyArr.push(thisAccMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var discountLastMoneyNum =$("#DiscountLastMoney").val()-0; //优惠后金额
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text()-0; //本次付款或者收款
- if(accountMoneyTotal===0){
- $.messager.alert('错误提示',"请填写金额后保存",'warning');
- return;
- }
- if(accountArr.length && accountMoneyArr.length) {
- $("#AccountId").attr("data-accountArr",JSON.stringify(accountArr)).attr("data-accountMoneyArr",JSON.stringify(accountMoneyArr)); //json数据存储
- }
- $("#ChangeAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
- $("#Debt").val((discountLastMoneyNum-accountMoneyTotal).toFixed(2)); //本次欠款
- $("#depotHeadAccountDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#AccountId").attr("data-accountArr")){
- $("#depotHeadAccountDlg").dialog('close');
- }
- else {
- $("#depotHeadAccountDlg").dialog('close');
- $("#AccountId").val("").removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- }
- //多账户-取消按钮
- $("#cancelDepotHeadAccountDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //多账户-右上角的关闭按钮
- $("#depotHeadAccountDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
- }
- //点击多账户,弹出输入框
- $("#AccountId").off("change").on("change",function(){
- var selectText = $(this).children('option:selected').text();
- if(selectText === "多账户"){
- $("#ChangeAmount").prop("readonly","readonly");
- depotHeadAccountDlgFun();
- $(".many-account-ico").show(); //显示多账户小图标
- }
- else{
- $(this).removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- }
- $(".many-account-ico").hide(); //隐藏多账户小图标
- });
-
- //结算账户-多账户小图标-点击事件
- $(".many-account-ico").off("click").on("click",function(){
- depotHeadAccountDlgFun();
- //给弹窗赋值-多账户数据
- var accountArr = $("#AccountId").attr("data-accountArr");
- accountArr = JSON.parse(accountArr);
- var accountMoneyArr = $("#AccountId").attr("data-accountMoneyArr");
- accountMoneyArr = JSON.parse(accountMoneyArr);
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".account-id-dlg").val(accountArr[index]);
- $(this).find(".account-money-dlg").val(accountMoneyArr[index]);
- });
- $("#accountMoneyTotalDlg").text($("#ChangeAmount").val());
- });
-
- //点击采购费用、销售费用的事件
- $(".other-money-ico").off("click").on("click",function(){
- $('#otherMoneyDlg').dialog('open').dialog('setTitle','
'+ listSubType +'费用');
- $("#otherMoneyDlg .money-dlg .money-content-tmp").remove(); //先移除输入栏目
- $("#otherMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#otherMoneyDlg .tabs-tmp .money-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#otherMoneyDlg .tabs-tmp tbody").html();
- var moneyDlgHead = $("#otherMoneyDlg .money-head-tmp");
- moneyDlgHead.after(contentTmp);
- }
-
- //获取支出项目信息
- function moneyDlgFun() {
- var options = "";
- if(outItemList !=null){
- for(var i = 0 ;i < outItemList.length;i++) {
- var money = outItemList[i];
- options += '';
- }
- $(".money-id-dlg").empty().append("").append(options);
- }
- }
- moneyDlgFun(); //获取支出项目信息
- $("#otherMoneyDlg .tabs-tmp").hide(); //隐藏模板
-
- //支出项目的金额输入框事件
- $("#otherMoneyDlg .money-dlg .other-money-dlg").off("keyup").on("keyup",function(){
- var totalMoneyNum = 0;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var eachOtherMoney = $(this).find(".other-money-dlg").val()-0;
- totalMoneyNum += eachOtherMoney;
- });
- $("#otherMoneyTotalDlg").text(totalMoneyNum);
- });
-
- //支出项目列表的切换事件
- $("#otherMoneyDlg .money-dlg .money-id-dlg").off("change").on("change",function(){
- var selectItem = $(this).children('option:selected').text();
- if(selectItem === ""){
- var thisMoneyDom = $(this).closest(".money-content-tmp").find(".other-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text() - 0;
- $("#otherMoneyTotalDlg").text(otherMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //支出项目为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveOtherMoneyDlg").off("click").on("click", function(){
- //完成支出项目的json数据存储
- var itemArr = []; //支出项目id数组
- var itemMoneyArr = []; //支出项目金额数组
- var errorIndex = -1;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var thisId = $(this).find(".money-id-dlg").val();
- var thisMoney = $(this).find(".other-money-dlg").val();
- if(!thisId && thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && !thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && thisMoney) {
- itemArr.push(thisId);
- itemMoneyArr.push(thisMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text()-0; //合计金额
- if(otherMoneyTotal === 0){ //0的时候清空缓存数据
- $("#OtherMoney").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr");
- }
- if(itemArr.length && itemMoneyArr.length) {
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
- $("#OtherMoney").val(otherMoneyTotal); //给采购费用、销售费用赋值
- $("#otherMoneyDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#OtherMoney").attr("data-itemArr")){
- $("#otherMoneyDlg").dialog('close');
- }
- else {
- $("#otherMoneyDlg").dialog('close');
- $("#OtherMoney").val("").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr"); //将下拉置空并把缓存参数清空
- }
- }
- //费用-取消按钮
- $("#cancelOtherMoneyDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //费用-右上角的关闭按钮
- $("#otherMoneyDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
-
- //给弹窗赋值-采购费用、销售费用数据
- var itemArr = $("#OtherMoney").attr("data-itemArr");
- itemArr = JSON.parse(itemArr);
- var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr");
- itemMoneyArr = JSON.parse(itemMoneyArr);
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".money-id-dlg").val(itemArr[index]);
- if(itemMoneyArr[index]!="undefined"){
- $(this).find(".other-money-dlg").val(itemMoneyArr[index]);
- }
- });
- $("#otherMoneyTotalDlg").text($("#OtherMoney").val());
- });
-}
-
-function showDepotHeadDetails(pageNo,pageSize){
- var materialParam = $.trim($("#searchMaterial").val());
- var beginTime = $.trim($("#searchBeginTime").val());
- var endTime = $.trim($("#searchEndTime").val());
- if(beginTime) {
- beginTime = beginTime + ' 00:00:00';
- }
- if(endTime) {
- endTime = endTime + ' 23:59:59';
- }
- $.ajax({
- type: "get",
- url: "/depotHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- subType: listSubType,
- state: $.trim($("#searchState").val()),
- number: $.trim($("#searchNumber").val()),
- beginTime: beginTime,
- endTime: endTime,
- materialParam: materialParam,
- depotIds: depotString
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#depotHeadFM .datagrid-body");
- var footer =$("#depotHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
- //点击商品下拉框,自动加载数量、单价、金额
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //点击库存文本框,字段计算库存
- body.find("[field='Stock']").find(input).off("click").on("click",function(){
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- var monthTime = getNowFormatMonth();
- if(depotId && mId){
- var ratio = body.find("[field='Unit']").find(input).attr("data-ratio");
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //在新增的时候,这个ratio有值;在编辑的时候,这个ratio为undefined
- var type = "click"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratio, type);
- }
- else{
- body.find("[field='Stock']").find(input).val(0).attr("data-stock",0); //加载库存数据
- }
- });
- //修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计
- body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber =$(this).val()-0; //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
-
- });
- //修改单价,自动计算金额和合计
- body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice =$(this).val()-0; //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击单价,自动提示参考价格列表
- body.find("[field='UnitPrice']").find(input).off("click").on("click",function(){
- var self = this;
- var mValue = body.find("[field='MaterialId'] .combo-value").attr("value"); //获取选中的商品id
- if(!mValue) {
- return;
- }
- else {
- if(listTitle!="销售出库列表" && listTitle!="采购退货列表" && listTitle!="其它出库列表" && listTitle!="调拨出库列表") {
- return;
- }
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mValue - 0
- },
- success: function(res){
- if(res && res.rows && res.rows[0]) {
- var retailPrice = res.rows[0].RetailPrice;
- var presetPriceOne = res.rows[0].PresetPriceOne;
- var presetPriceTwo = res.rows[0].PresetPriceTwo;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- 批发价:" + presetPriceTwo + "
";
- temp +="- 零售价:" + retailPrice + "
";
- temp +="
";
- temp +="
";
- if($('.price-list').length){
- $('.price-list').remove(); //如果存在价格列表先移除
- }
- else {
- if(presetPriceTwo != undefined){ //多单位的商品
- $(self).after(temp); //加载列表信息
- }
- }
- $('.price-list ul li').off("click").on("click",function(){
- var price = $(this).text();
- price = price.substring(price.indexOf(":") + 1);
- $(self).val(price);
- $(self).keyup(); //模拟键盘操作
- $('.price-list').remove(); //移除价格列表
- });
- //点击空白处移除价格列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.price-list').remove(); //移除价格列表
- });
- }
- },
- error: function(){
- $.messager.alert('错误提示','查询商品信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- //修改含税单价,自动计算单价、金额、税额、价税合计和合计
- body.find("[field='TaxUnitPrice']").find(input).off("keyup").on("keyup",function(){
- var TaxUnitPrice =$(this).val()-0; //含税单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var UnitPrice = TaxUnitPrice/(1+taxRate/100); //计算单价
- body.find("[field='UnitPrice']").find(input).val((UnitPrice).toFixed(2)); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改金额,自动计算单价、税额、价税合计和合计
- body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var AllPrice =$(this).val()-0; //金额
- var UnitPrice = (AllPrice/OperNumber).toFixed(2);
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税率,自动计算含税单价、税额、价税合计和合计
- body.find("[field='TaxRate']").find(input).off("keyup").on("keyup",function(){
- var taxRate =$(this).val()-0; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税额,自动计算税率、含税单价、价税合计和合计
- body.find("[field='TaxMoney']").find(input).off("keyup").on("keyup",function(){
- var taxMoney =$(this).val()-0; //税额
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = taxMoney/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改价税合计,自动计算税率、含税单价、税额和合计
- body.find("[field='TaxLastMoney']").find(input).off("keyup").on("keyup",function(){
- var taxLastMoney =$(this).val()-0; //价税合计
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = (taxLastMoney-AllPrice)/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
-
- //加载税率
- if(thisTaxRate) {
- body.find("[field='TaxRate']").find(input).val(thisTaxRate);
- }
- else {
- body.find("[field='TaxRate']").find(input).val(0); //默认为0
- }
-
- //在商品类型加载 组装件、普通子件
- var mType = body.find("[field='MType']");
- var rowListLength = mType.find(input).closest(".datagrid-row").attr("datagrid-row-index");
- var mTypeValue = "组合件";
- if(rowListLength > 0){
- mTypeValue = "普通子件";
- }
- },500);
-}
-
-//结束编辑
-function endEditing() {
- if (editIndex == undefined) { return true }
- if ($('#materialData').datagrid('validateRow', editIndex)) {
- //仓库信息
- var edDepot = $('#materialData').datagrid('getEditor', {index:editIndex,field:'DepotId'});
- var DepotName = $(edDepot.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName;
- //商品信息
- var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'});
- var MaterialName = $(edMaterial.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName;
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#materialData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append(){
- if (endEditing()) {
- $('#materialData').datagrid('appendRow', {DepotId:defDepotId});
- editIndex = $('#materialData').datagrid('getRows').length - 1;
- $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function batchDel(){
- /**
- * 重写一下删除的逻辑
- * 获取所有选中行,直接从列表中移除
- * 点击保存时,将需要后台删除的数据提交到服务器
- * **/
- /**
- * create by: qiankunpingtai
- * create time: 2019/3/20 16:26
- * description:
- * 这个地方比较坑的,花了一个多小时才搞明白为什么
- * 1、删除之前必须先调用endEditing结束编辑
- * 2、如果只是调用endEditing结束编辑那么正在编辑行的被选中状态会被去掉
- * 所以要在调用endEditing先获取选中的行
- */
- //如果编辑的行一开始是选中状态,结束编辑后仍然是选中状态
- var row = $('#materialData').datagrid('getChecked');
- if (endEditing()) {
- if (row.length == 0) {
- $.messager.alert('删除提示', '没有记录被选中!', 'info');
- return;
- }
- if (row.length > 0) {
- $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条单据信息吗?', function (r) {
- if (r) {
- for (var i = 0; i < row.length; i++) {
- $('#materialData').datagrid('deleteRow', $('#materialData').datagrid("getRowIndex", row[i]));
- }
- }
- });
- }
- }
-}
-function removeit(){
- if (editIndex == undefined) { return }
- $('#materialData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#materialData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData(type) {
- var change = $('#materialData').datagrid('getChanges').length;
- if(type =="add" && !change) {
- $.messager.alert('提示','请输入明细信息!','warning');
- return false;
- }
- var row = $('#materialData').datagrid('getRows');
- if(!row.length){
- $.messager.alert('提示',"请输入明细信息!",'info');
- return false;
- }
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if (row[i].DepotId == "" || row[i].MaterialId == "" || row[i].OperNumber == "" || row[i].UnitPrice === "" || row[i].AllPrice === "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-
-/**
- * 新增单据主表及单据子表
- * */
-function addDepotHeadAndDetail(url,infoStr){
- var inserted = null;
- if(pageType === "skip") {
- inserted = $("#materialData").datagrid('getChanges', "updated");
- } else {
- inserted = $("#materialData").datagrid('getChanges', "inserted");
- }
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated)
- }),
- success: function (tipInfo){
-
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
-
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
-
-
- });
-}
-/**
- * 修改单据主表及单据子表
- * */
-function updateDepotHeadAndDetail(url,infoStr,preTotalPrice){
- var inserted = $("#materialData").datagrid('getChanges', "inserted");
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- id:url.substring(url.lastIndexOf("?id=")+4,url.length),
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- preTotalPrice:preTotalPrice
- }),
- success: function (tipInfo){
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
- if (endEditing()) {
- $('#materialData').datagrid('acceptChanges');
- }
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-
-
-
diff --git a/erp_web/js/pages/materials/sale_orders_list.js b/erp_web/js/pages/materials/sale_orders_list.js
deleted file mode 100644
index 5918b416..00000000
--- a/erp_web/js/pages/materials/sale_orders_list.js
+++ /dev/null
@@ -1,2435 +0,0 @@
-//初始化界面
-var defDepotId = null;
-var kid = sessionStorage.getItem("userId");
-var pageType = getUrlParam('t'); //获取页面类型传值
-var depotList = null;
-var depotID = null;
-var supplierList = null;
-var supplierID = null;
-var personList = null;
-var personID = null;
-var ProjectSearch=null;
-var userBusinessList=null;
-var userdepot=null;
-var url;
-var depotHeadID = 0;
-var preTotalPrice = 0; //前一次加载的金额
-var orgDepotHead = "";
-var editIndex = undefined;
-/**默认编号有意义吗,不如空着吧*/
-var orgDefaultId=''; //单位默认编号
-var orgDefaultList; //存储查询出来的会员列表
-var accountList; //账户列表
-var outItemList; //支出项目列表
-var thisTaxRate = 0; //当前税率,选择供应商或者客户的时候设置
-var oldNumber = ""; //编辑前的单据编号
-var oldId = 0; //编辑前的单据Id
-var otherColumns = true; //明细中的‘别名’列是否显示
-var btnEnableList = getBtnStr(); //获取按钮的权限
-var mPropertyList = ""; //商品属性列表
-var defaultAccountId = 0; //默认账户id
-//改变宽度和高度
-$("#searchPanel").panel({width:webW-2});
-$("#tablePanel").panel({width:webW-2});
-var listTitle = "销售订单列表"; //单据标题
-var depotString = "|"; //店铺id列表
-var listType = "其它";//入库 出库
-var listSubType = "销售订单";//采购 销售等
-var payTypeTitle = "隐藏"; //付款 收款
-var organUrl ="/supplier/findBySelect_cus?UBType=UserCustomer&UBKeyId=" + kid;//组织数据接口地址
-var amountNum ="XSDD";//单据编号开头字符
-$(function(){
- //初始化系统基础信息
- initSystemData_UB();
- initSelectInfo_UB();
- initSystemData_depot();
- initSelectInfo_depot();
- initSystemData_person();
- initSelectInfo_person();
- initSystemData_account();
- initSelectInfo_account();
- initSupplier(); //供应商
- initSalesman(); //销售人员
- initOutItemList(); //初始化支出项目
- initMProperty(); //初始化商品属性
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
-});
-//初始化系统基础信息
-function initSystemData_UB(){
- $.ajax({
- type:"get",
- url: "/userBusiness/getBasicData",
- data: ({
- KeyId:kid,
- Type:"UserDepot"
- }),
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if (res && res.code === 200) {
- userBusinessList = res.data.userBusinessList;
- }
- else {
- userBusinessList = null;
- }
- }
- });
-
-}
-//初始化页面选项卡
-function initSelectInfo_UB(){
-
- if(userBusinessList !=null)
- {
- if(userBusinessList.length>0)
- {
- //用户对应的仓库列表 [1][2][3]...
- userdepot =userBusinessList[0].value;
- }
- }
-}
-
-
-//初始化系统基础信息
-function initSystemData_depot(){
- $.ajax({
- type:"get",
- url: "/depot/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200){
- depotList = res.data;
- } else {
- $.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error');
- return;
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_depot(){
- var options = "";
-
- if(depotList !=null)
- {
- options = "";
- for(var i = 0 ;i < depotList.length;i++)
- {
- var depot = depotList[i];
-
- if(userdepot!=null)
- {
- if(userdepot.indexOf("["+depot.id+"]")!=-1)
- {
- if(depot.isDefault){
- defDepotId = depot.id;
- }
- options += '';
- depotString = depotString + depot.id + ",";
- }
- }
- if(depot.type === 1){
- depotString = depotString + depot.id + ",";
- }
- }
- depotString = depotString.substring(1, depotString.length-1);
- $("#ProjectId").empty().append(options);
- $("#AllocationProjectId").empty().append(options);
- $("#searchProjectId").empty().append('').append(options);
- }
-}
-
-//初始化供应商、客户、散户信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onLoadSuccess: function(res) {
- var data = $(this).combobox('getData');
- for(var i = 0; i<= data.length; i++){
- if(data && data[i] && data[i].supplier === "非会员"){
- orgDefaultId = data[i].id;
- }
- }
- },
- onSelect: function(rec){
- $.ajax({
- type:"get",
- url: "/supplier/findById",
- data: {
- supplierId: rec.id
- },
- dataType: "json",
- success: function (res){
- if(res && res.code === 200) {
- if(res.data && res.data[0]){
- thisTaxRate = res.data[0].taxRate; //设置当前的税率
- }
- }
- },
- error:function(){
-
- }
- });
- }
- });
-}
-
-//初始化销售人员
-function initSalesman(){
- $('#Salesman').combobox({
- url: "/person/getPersonByNumType?type=1",
- valueField:'id',
- textField:'name',
- multiple: true
- });
-}
-
-//初始化收入项目列表
-function initOutItemList(){
- $.ajax({
- type:"get",
- url: "/inOutItem/findBySelect?type=out",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res){
- if(res){
- outItemList = res;
- }
- },
- error:function(){
-
- }
- });
-}
-
-//初始化商品属性
-function initMProperty(){
- $.ajax({
- type: "get",
- url: "/materialProperty/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- name: ""
- }),
- currentPage: 1,
- pageSize: 100
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- var thisRows = res.data.page.rows;
- for (var i = 0; i < thisRows.length; i++) {
- if (thisRows[i].enabled) {
- mPropertyList += thisRows[i].nativename + ",";
- }
- }
- if (mPropertyList) {
- mPropertyList = mPropertyList.substring(0, mPropertyList.length - 1);
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化系统基础信息
-function initSystemData_person(){
- $.ajax({
- type:"get",
- url: "/person/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- personList = res.data.personList;
- }
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_person(){
- var options1 = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="仓管员")
- {
- options1 += '';
- }
- }
- $("#HandsPersonId").empty().append(options1);
- }
-}
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null){
- options = "";
- options += "";
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- if(account.isdefault) {
- defaultAccountId = account.id; //给账户赋值默认id
- }
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#depotHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- if(pageType === "skip") {
- var oldRowInfo = sessionStorage.getItem("rowInfo");
- editDepotHead(oldRowInfo); //自动弹出编辑框,带缓存数据
- }
- var hideType = undefined;
- var isHiddenStatus = true;
- if(payTypeTitle === "隐藏"){
- hideType = true; //隐藏当前列
- }
- var tableToolBar = [
- {
- id:'addDepotHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addDepotHead();
- }
- },
- {
- id:'deleteDepotHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteDepotHead();
- }
- }
- ];
- //如果允许的按钮列表中存在就显示,3-代表审核|反审核的权限
- if(btnEnableList && btnEnableList.indexOf(3)>-1){
- isHiddenStatus = false; //显示
- tableToolBar.push({
- id:'okDepotHead',
- text:'审核',
- iconCls:'icon-ok',
- handler:function() {
- setStatusFun();
- }
- },
- {
- id:'undoDepotHead',
- text:'反审核',
- iconCls:'icon-undo',
- handler:function() {
- setUnStatusFun();
- }
- });
- }
- else {
- isHiddenStatus = true; //隐藏
- }
- var isShowLastMoneyColumn = true; //是否显示优惠后金额和价税合计,true为隐藏,false为显示
- var isShowOrganNameColumn = false; //是否显示供应商、客户等信息,true为隐藏,false为显示
- var organNameTitle = "客户名称";//组织名称标题
- var opWidth = 120; //操作宽度
- var opTitle = "转销售出库"; //跳转按钮的标题
- $('#tableData').datagrid({
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: true,
- //交替出现背景
- striped : true,
- pageSize: 10,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:opWidth,
- formatter:function(value, rec,index) {
- var str = '';
- var orgId = rec.organid? rec.organid:0;
- str += '
';
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
- { title: '单据编号',field: 'number',width:135, formatter:function (value,rec) {
- if(rec.linknumber) {
- return value + "[转]";
- } else {
- return value;
- }
- }
- },
- { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
- if(value) {
- return value.replace(",",",");
- }
- }
- },
- { title: '单据日期',field: 'opertimeStr',width:130},
- { title: '操作员',field: 'operpersonname',width:60},
- { title: '金额合计',field: 'totalprice',width:60},
- { title: '含税合计',field: 'totaltaxlastmoney',hidden:isShowLastMoneyColumn,width:60,formatter:function(value,rec){
- return (rec.discountmoney + rec.discountlastmoney).toFixed(2);
- }
- },
- { title: '优惠后金额',field: 'discountlastmoney',hidden:isShowLastMoneyColumn,width:80},
- { title: payTypeTitle,field: 'changeamount',width:50,hidden:hideType},
- { title: '状态',field: 'status',hidden:isHiddenStatus, width:70,align:"center",formatter:function(value){
- if(value === "0") {
- return "未审核";
- } else if(value === "1") {
- return "已审核";
- } else if(value === "2") {
- return "已转销售";
- }
- }
- }
- ]],
- toolbar:tableToolBar,
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//查找库存的方法
-function findStockNumById(depotId, mId, monthTime, body, input, ratio, type){
- var thisRatio = 1; //比例
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (rec) {
- if(rec && rec.code === 200 && rec.data && rec.data[0]) {
- var loadRatio = 1; //在单位输入框上面加载比例字段
- if(rec.data[0].unit) { //如果存在计量单位信息
- loadRatio = 1;
- }
- else{
- var unitName = rec.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- thisRatio = unitName.substring(unitName.indexOf(":")+1).replace(")","");
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- unitSetInput = rec.data[0].firstoutunit;
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = thisRatio;
- }
- }
- //查询库存
- $.ajax({
- type: "get",
- url: '/depotItem/findStockNumById',
- data:{
- projectId: depotId,
- materialId: mId
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if (res.data && res.data.page && res.data.page[0]) {
- var thisStock = res.data.page[0].thisSum;
- if (type == "select") { //选择下拉框的时候
- if (ratio != undefined && ratio != 1) {
- loadRatio = ratio;
- }
- }
- else if (type == "click") { //点击库存的时候
- if (ratio != undefined) {
- loadRatio = ratio;
- }
- }
- thisStock = (thisStock / loadRatio).toFixed(2);
- body.find("[field='Stock']").find(input).val(thisStock).attr("data-stock", res.data.page[0].thisSum); //加载库存数据
- }
- else {
- body.find("[field='Stock']").find(input).val(0).attr("data-stock", 0); //加载库存数据
- }
- body.find("[field='Stock']").find(input).prop("readonly", "readonly"); //设置库存数据为只读
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
- }
- },
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- }
- });
-}
-//优惠率、合计的统计方法
-function statisticsFun(body,UnitPrice,OperNumber,footer,taxRate){
- var TotalPrice = 0;
- var taxLastMoneyTotal = 0;
- //金额的合计
- body.find("[field='AllPrice']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + UnitPrice*OperNumber;
- footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); //金额的合计
- //价税合计的总计
- body.find("[field='TaxLastMoney']").each(function(){
- if($(this).find("div").text()!==""){
- taxLastMoneyTotal = taxLastMoneyTotal + (parseFloat($(this).find("div").text().toString())-0);
- }
- });
- taxLastMoneyTotal = taxLastMoneyTotal + (UnitPrice*OperNumber*(1+taxRate/100));
- footer.find("[field='TaxLastMoney']").find("div").text((taxLastMoneyTotal).toFixed(2)); //价税合计的页脚总计
- var discount = $("#Discount").val(); //优惠率
- var discountMoney = (taxLastMoneyTotal*discount/100).toFixed(2);
- $("#DiscountMoney").val(discountMoney);//优惠金额
- var discountLastMoney = (taxLastMoneyTotal*(1-discount/100)).toFixed(2)
- $("#DiscountLastMoney").val(discountLastMoney);//优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
-
-}
-//初始化表格数据-商品列表-编辑状态
-function initTableData_material(type,TotalPrice){
- var body,footer,input; //定义表格和文本框
- var ratio = 1; //比例-品名专用
- var ratioDepot = 1; //比例-仓库用
- var monthTime = getNowFormatMonth();
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var depotHeadName = ""; //仓库名称
- var depotUrl = ""; //仓库接口地址
- var depotTextField = ""; //仓库下拉名称
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var anotherDepotUrl = ""; //对方仓库接口地址
- var anotherDepotTextField = "";
- depotHeadName = "仓库名称";
- depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- depotTextField = "depotName";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialData').datagrid({
- height:245,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: '商品类型',field: 'MType',editor:'validatebox',hidden:isShowMaterialTypeColumn,width:80},
- { title: depotHeadName, field: 'DepotId', editor: 'validatebox', width: 90,
- formatter: function (value, row, index) {
- return row.DepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: depotTextField,
- method: 'get',
- url: depotUrl,
- onSelect:function(rec){
- var depotId = rec.id;
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- if(mId){
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratioDepot, type);
- }
- }
- }
- }
- },
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialId',width:230,
- formatter:function(value,row,index){
- return row.MaterialName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'MaterialName',
- method:'get',
- url: "/material/findBySelect",
- panelWidth: 300, //下拉框的宽度
- //全面模糊匹配,过滤字段
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onBeforeLoad: function(param){
- param.mpList = mPropertyList; //商品属性
- },
- onSelect:function(rec){
- if(rec) {
- var mId = rec.Id;
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (res) {
- if(res && res.code === 200 && res.data && res.data[0]) {
- var retailPrice = res.data[0].retailprice-0; //零售价格
- var presetPriceOne = res.data[0].presetpriceone-0; //预计采购价
- var presetPriceTwo = res.data[0].presetpricetwo-0; //批发价
- var firstInUnit = res.data[0].firstinunit; //首选入库单位
- var firstOutUnit = res.data[0].firstoutunit; //首选出库单位
- var basicPresetPriceOne = ""; //多单位-入库-基础价格
- var basicPresetPriceTwo = ""; //多单位-出库-基础价格
- var retailPriceOne = ""; //多单位-入库-零售价格
- var otherPresetPriceOne = ""; //多单位-入库-其他价格
- var otherPresetPriceTwo = ""; //多单位-出库-其他价格
- var retailPriceTwo = ""; //多单位-出库-零售价格
- var basicUnit = ""; //基础单位
- var otherUnit = ""; //其他单位
- if(!res.data[0].unit){
- var ps = res.data[0].pricestrategy;
- var psObj = JSON.parse(ps);
- basicPresetPriceOne = psObj[0].basic.PresetPriceOne-0;
- basicPresetPriceTwo = psObj[0].basic.PresetPriceTwo-0;
- retailPriceOne = psObj[0].basic.RetailPrice-0;
- otherPresetPriceOne = psObj[1].other.PresetPriceOne-0;
- otherPresetPriceTwo = psObj[1].other.PresetPriceTwo-0;
- retailPriceTwo = psObj[1].other.RetailPrice-0;
- basicUnit = psObj[0].basic.Unit;
- otherUnit = psObj[1].other.Unit;
- }
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- if(res.data[0].unit){ //如果存在计量单位信息
- ratio = 1; //重置比例为1
- body.find("[field='Unit']").find(input).val(res.data[0].unit); //设置-计量单位信息
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- body.find("[field='Unit']").find(input).off("click"); //移除点击事件
- body.find("[field='Unit']").find(input).attr("data-ratio",ratio); //修改比例缓存信息
- }
- else {
- var unitName = res.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- var loadRatio = 1; //在单位输入框上面加载比例字段
- unitSetInput = res.data[0].firstoutunit; //给单位文本框赋值
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = ratio;
- }
- body.find("[field='Unit']").find(input).val(unitSetInput).attr("data-ratio", loadRatio); //设置-首选单位
-
- body.find("[field='Unit']").find(input).off("click").on("click",function(){
- if(basicUnit && otherUnit) {
- var self = this;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- " + basicUnit + "
";
- temp +="- " + otherUnit + "
";
- temp +="
";
- temp +="
";
- if($('.unit-list').length){
- $('.unit-list').remove(); //如果存在计量单位列表先移除
- }
- else {
- $(self).after(temp); //加载列表信息
- }
- //计量单位列表的单击事件
- $('.unit-list ul li').off("click").on("click",function(){
- var unit = $(this).text();
- var thisRatio = $(this).attr("data-ratio"); //获取比例
- $(self).val(unit).attr("data-ratio", thisRatio);
- $(self).keyup(); //模拟键盘操作
- $('.unit-list').remove(); //移除计量单位列表
- var stock = body.find("[field='Stock']").find(input).attr("data-stock"); //从缓存中取值
- var type = $(this).attr("data-type");
- var UnitPrice = 0;
- if(type === "basic"){
- UnitPrice = basicPresetPriceTwo;
- body.find("[field='Stock']").find(input).val(stock); //修改库存
- }
- else if(type === "other"){
- UnitPrice = otherPresetPriceTwo;
- body.find("[field='Stock']").find(input).val((stock/ratio).toFixed(2)); //修改库存
- }
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //获取数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击空白处移除计量单位列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.unit-list').remove(); //移除计量单位列表
- });
- }
- });
- }
- var detailPrice = 0; //明细列表-单价
- if(res.data[0].unit) { //如果存在计量单位信息
- detailPrice = presetPriceTwo;
- }
- else {
- if(firstOutUnit==basicUnit) {
- detailPrice = basicPresetPriceTwo;
- }
- else if(firstOutUnit==otherUnit){
- detailPrice = otherPresetPriceTwo;
- }
- }
- body.find("[field='OperNumber']").find(input).val(1); //数量初始化为1
- //单价和总价赋值
- if(!detailPrice) {
- detailPrice = 0;
- }
- body.find("[field='UnitPrice']").find(input).val(detailPrice);
- body.find("[field='AllPrice']").find(input).val(detailPrice);
- var taxRate = body.find("[field='TaxRate']").find(input).val()-0; //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((detailPrice*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,detailPrice,1,footer,taxRate);
-
- //查询库存信息
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- if(depotId) {
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, loadRatio, type);
- }
- }
- },
- error: function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- }
- });
- }
- }
- }
- }
- },
- { title: '库存',field: 'Stock',editor:'validatebox',width:70},
- { title: anotherDepotHeadName, field: 'AnotherDepotId',editor:'validatebox',hidden:isShowAnotherDepot,width:90,
- formatter: function (value, row, index) {
- return row.AnotherDepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: anotherDepotTextField,
- method: 'get',
- url: anotherDepotUrl
- }
- }
- },
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率(%)',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batchDel(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = 0;
- var TaxLastMoney = 0;
- var DiscountMoney = $("#DiscountMoney").val()-0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoney").val()-0; //优惠后金额
- if(type === "edit") {
- AllPrice = TotalPrice;
- TaxLastMoney = DiscountMoney + DiscountLastMoney;
- }
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": TaxLastMoney
- });
- data.footer = array;
- $("#materialData").datagrid('loadData',data);
- //如果是订单跳转到采购或销售
- if(pageType === "skip") {
- var skipList = $("#depotHeadFM .datagrid-body tr");
- //逐条自动点击每行数据
- skipList.each(function (i) {
- setTimeout(function () {
- skipList.eq(i).find("[field='Stock']").click();
- },(i+1)*1000);
- });
- }
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//初始化表格数据-商品列表-查看状态
-function initTableData_material_show(TotalPrice){
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var depotHeadName = ""; //仓库的列的标题
- depotHeadName = "仓库名称";
- var isShowTaxColumn = true; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialDataShow').datagrid({
- height:245,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- onClickRow: onClickRow,
- columns:[[
- { title: '商品类型',field: 'MType',width:80, hidden:isShowMaterialTypeColumn},
- { title: depotHeadName,field: 'DepotName',editor:'validatebox',width:90},
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialName',width:230},
- { title: anotherDepotHeadName,field: 'AnotherDepotName',hidden:isShowAnotherDepot,width:90},
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validattebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = TotalPrice;
- var DiscountMoney = $("#DiscountMoneyShow").text() - 0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoneyShow").text() - 0; //优惠后金额
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": DiscountMoney + DiscountLastMoney
- });
- data.footer = array;
- $("#materialDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showDepotHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除单据信息
-function deleteDepotHead(depotHeadID, thisOrganId, totalPrice, status){
- if(status == "1" || status == "2") {
- $.messager.alert('删除提示','已审核和已转的单据不能删除!','warning');
- return;
- }
- $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
- if (r) {
- $.ajax({
- type:"post",
- // url: "/depotHead/" + depotHeadID + "/delete",
- url: "/depotHead/deleteDepotHeadAndDetail",
- dataType: "json",
- data:{
- id: depotHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
- return;
- }
- });
-
- }
- });
-}
-
-//订单转采购或销售
-function skipDepotHead(index, status){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- if(status == "0" || status == "2") {
- $.messager.alert('提示','未审核和已转的单据禁止操作!','warning');
- } else {
- sessionStorage.setItem("rowInfo", JSON.stringify(rowsdata)); //将单据信息存入缓存中
- parent.addTab("订单转销售", "../materials/sale_out_list.html?t=skip", "");
- }
-}
-
-//批量删除单据信息
-function batDeleteDepotHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条单据信息吗?',function(r)
- {
- if (r) {
- var ids = "";
- for (var i = 0; i < row.length; i++) {
- if (i == row.length - 1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- if (ids) {
- //批量删除
- $.ajax({
- type: "post",
- // url: "/depotHead/batchDelete",
- url: "/depotHead/batchDeleteDepotHeadAndDetail",
- dataType: "json",
- async: false,
- data: ({
- ids: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除单据信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('删除提示','没有能删除的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量审核
-function setStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('审核确认','确定要审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: "1",
- depotHeadIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('审核提示', '审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('审核提示','审核信息异常,请稍后再试!','error');
- return;
- }
- });
- } else {
- $.messager.alert('审核提示','没有能审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量反审核
-function setUnStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('反审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('反审核确认','确定要反审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type: "post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async: false,
- data: ({
- status: "0",
- depotHeadIDs: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('反审核提示', '反审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('反审核提示', '反审核信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('反审核提示','没有能反审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//生成单据编号
-function buildNumber() {
- $.ajax({
- type: "get",
- url: "/depotHead/buildNumber",
- success:function(res){
- if(res && res.code === 200){
- var obj = res.data;
- var defaultNumber = obj.DefaultNumber;
- var newNumber = amountNum + defaultNumber;
- $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
- }
- },
- error:function(){
- $.messager.alert('提示','生成单据编号失败!','error');
- }
- });
-}
-
-//新增信息
-function addDepotHead(){
- $('#depotHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- buildNumber(); //生成单据编号
- //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为0
- $("#Discount").val(0);
- $("#DiscountMoney").val(0);
- $("#DiscountLastMoney").val(0);
- $("#ChangeAmount").val(0);
- $("#Debt").val(0);
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- var addTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgDepotHead = "";
- depotHeadID = 0;
- initTableData_material("add"); //商品列表
- reject(); //撤销下、刷新商品列表
- $("#addOrgan").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加供应商信息');
- $('#supplierFM').form('clear');
- });
-
- $("#addMember").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加会员信息');
- $('#supplierFM').form('clear');
- });
- $("#addCustomer").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加客户信息');
- $('#supplierFM').form('clear');
- });
- url = '/depotHead/addDepotHeadAndDetail';
-}
-
-//编辑信息
-function editDepotHead(index, status){
- if(status == "1" || status == "2") {
- $.messager.alert('编辑提示','已审核和已转的单据不能编辑!','warning');
- return;
- }
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata ='';
- if(Number(index).toString()=='NaN'){
- rowsdata=$.parseJSON(index);
- }else{
- rowsdata=$("#tableData").datagrid("getRows")[index];
- }
- $("#ProjectId").focus().val(rowsdata.projectid);
- var ProjectId=rowsdata.projectid;
- if(ProjectId!='') {
- initSystemData_person(ProjectId);
- initSelectInfo_person();
- }
- var TotalPrice = rowsdata.totalprice; //合计金额
- if(pageType === "skip") { //从订单跳转过来
- buildNumber(); //生成单据编号
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- $("#LinkNumber").val(rowsdata.number); //关联订单号
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- $("#DiscountLastMoney").val(TotalPrice); //优惠后金额
- $("#ChangeAmount").val(TotalPrice).attr("data-changeamount", TotalPrice);
- } else {
- $("#Number").val(rowsdata.number).attr("data-defaultNumber",rowsdata.number);
- $("#OperTime").val(rowsdata.opertimeStr);
- $("#LinkNumber").val(rowsdata.linknumber==undefined?"":rowsdata.linknumber); //关联订单号
- $("#AccountId").val(rowsdata.accountid); //账户Id
- $("#DiscountLastMoney").val(rowsdata.discountlastmoney==undefined?"0.00":rowsdata.discountlastmoney); //优惠后金额
- $("#ChangeAmount").val(rowsdata.changeamount).attr("data-changeamount", rowsdata.changeamount);
- }
- $('#OrganId').combobox('setValue', rowsdata.organid==undefined?'':rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#Remark").val(rowsdata.remark);
- $("#Discount").val(rowsdata.discount==undefined?"0":rowsdata.discount);
- $("#DiscountMoney").val(rowsdata.discountmoney==undefined?"0.00":rowsdata.discountmoney);
- $("#Debt").val(Number((rowsdata.discountlastmoney==undefined?'0.00':rowsdata.discountlastmoney-rowsdata.changeamount)).toFixed(2));
- $("#AccountDay").val(rowsdata.accountday==undefined?"":rowsdata.accountday); //结算天数
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于扣预付款
- $("#AllocationProjectId").val(rowsdata.allocationprojectid);
- oldNumber = rowsdata.number; //记录编辑前的单据编号
- oldId = rowsdata.id; //记录单据Id
- var editTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- depotHeadID = rowsdata.id;
-
-
- //采购入库、销售出库的多账户加载
- if(rowsdata.accountidlist!=undefined && rowsdata.accountmoneylist!=undefined){
- $("#AccountId").val("many"); //下拉框选中多账户
- var accountArr = rowsdata.accountidlist.split(",");
- var accountMoneyArr = rowsdata.accountmoneylist.split(",");
- accountMoneyArr = changeListFmtPlus(accountMoneyArr) //将数组单个金额中的数值转为正数
-
- $("#AccountId").attr("data-accountArr", JSON.stringify(accountArr)).attr("data-accountMoneyArr", JSON.stringify(accountMoneyArr)); //json数据存储
- $(".many-account-ico").show(); //显示多账户的ico图标
- }
-
- //采购入库、销售出库的费用数据加载
- if(rowsdata.othermoneylist &&rowsdata.othermoneyitem){
- $("#OtherMoney").val(rowsdata.othermoney==undefined?"0":rowsdata.othermoney); //采购费用、销售费用
- var itemArr = rowsdata.othermoneylist.split(",");
- var itemMoneyArr = rowsdata.othermoneyitem.split(",");
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
-
- initTableData_material("edit",TotalPrice); //商品列表
- reject(); //撤销下、刷新商品列表
- if(pageType === "skip") {
- url = '/depotHead/addDepotHeadAndDetail'; //如果是从订单跳转过来,则此处为新增的接口
- //jshjshjsh
- $("#depotHeadFM .datagrid-body").find("[field='DepotId']").click();
- } else {
- url = '/depotHead/updateDepotHeadAndDetail?id=' + rowsdata.id; //更新接口
- }
-}
-
-//查看信息
-function showDepotHead(index){
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var manyAccountMoney = 0; //多账户合计-零售
- $("#ProjectIdShow").text(rowsdata.projectName);
- $("#NumberShow").text(rowsdata.number);
- $("#OperTimeShow").text(rowsdata.opertimeStr);
- $('#OrganIdShow').text(rowsdata.organName==undefined?'':rowsdata.organName);
- $("#HandsPersonIdShow").text(rowsdata.handsPersonName);
- if(rowsdata.accountName && rowsdata.accountName!=undefined){
- $("#AccountIdShow").text(rowsdata.accountName); //结算账户
- } else {
- var accountArr = (rowsdata.accountidlist==undefined?"":rowsdata.accountidlist).split(","); //账户id列表
- var accountMoneyArr =(rowsdata.accountmoneylist==undefined?"":rowsdata.accountmoneylist).split(","); //账户金额列表
- var accountIdShow = "";
- for(var j =0;j 查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- depotHeadID = rowsdata.id;
- initTableData_material_show(TotalPrice); //商品列表-查看状态
-}
-
-//绑定操作事件
-function bindEvent(){
- showDepotHeadDetails(1,initPageSize); //初始化时自动查询
- //搜索处理
- $("#searchBtn").off("click").on("click",function(){
- showDepotHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh',
- {
- pageNumber:1,
- pageSize:initPageSize
- });
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- //$("#searchProjectId").val("");
- $("#searchState").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //检查单据编号是否存在
- function checkDepotHeadNumber() {
- var thisNumber = $.trim($("#Number").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(thisNumber.length > 0 &&( oldNumber.length ==0 || thisNumber != oldNumber))
- {
- $.ajax({
- type:"get",
- url: "/depotHead/checkIsNumberExist",
- dataType: "json",
- async : false,
- data: ({
- DepotHeadID : oldId,
- Number : thisNumber
- }),
- success: function (tipInfo)
- {
- flag = tipInfo;
- if(tipInfo)
- {
- $.messager.alert('提示','抱歉,该单据编号已经存在','warning');
- return;
- }
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','检查单据编号是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
- //保存信息
- /**
- * 2019-01-25
- * 我对这个方法的实现结果存在严重怀疑,决定重构
- * 有如下疑点:
- * 1、保存完主表,返回结果后,再发起请求去操作子表,如何保证事务的一致性(业务数据一致性)
- * 2、保存完主表后,再通过selectmax的方式去获取主表主键id完全就是看人品的不可靠的思路
- * 修改计划:
- * 2019-01-25修改零售出库相关操作
- * 修改方式,重写url,将主从表操作合并
- *
- *
- * **/
- $("#saveDepotHead").off("click").on("click",function(){
- if(!$('#depotHeadFM').form('validate')){
- return;
- }
- else {
- //如果初始编号被修改了,就要判断单据编号是否存在
- if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
- //调用查询单据编号是否重名的方法
- if(checkDepotHeadNumber()){
- return;
- }
- }
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择购买单位!','warning');
- return;
- }
- if (editIndex != undefined) {
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- //进行明细的校验
- if(depotHeadID ==0) {
- //新增模式下
- if (!CheckData("add")) {
- return;
- }
- }
- else {
- //编辑模式下
- if (!CheckData("edit")) {
- return;
- }
- }
- var OrganId = null, ProjectId = null,AllocationProjectId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val())-0;
- var TotalPrice = $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text();
- if($('#OrganId').length){
- OrganId = $('#OrganId').combobox('getValue');
- }
- var accountMoneyList = $("#AccountId").attr("data-accountmoneyarr"); //账户金额列表-多账户
- var accountMoneyArr;
- if(accountMoneyList) {
- accountMoneyList = accountMoneyList.replace("[","").replace("]","").toString();
- var reg=new RegExp("\"","g"); //创建正则RegExp对象
- accountMoneyList = accountMoneyList.replace(reg,""); //替换所有的双引号
- accountMoneyArr = accountMoneyList.split(","); //转为数组
- }
- //零售时候,可以从会员预付款中扣款
- var thisPayType = "现付";
- var SalesmanStr = "";
- var getAccountID = $.trim($("#AccountId").val());
- if($("#AccountId").val() === "many"){ //多账户
- getAccountID = null;
- }
- var infoStr=JSON.stringify({
- Type: listType,
- SubType: listSubType,
- ProjectId: ProjectId,
- AllocationProjectId: AllocationProjectId,
- DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
- Number: $.trim($("#Number").val()),
- LinkNumber: $.trim($("#LinkNumber").val()),
- OperTime: $("#OperTime").val(),
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Salesman: SalesmanStr, //销售人员
- AccountId: getAccountID,
- ChangeAmount: ChangeAmount, //付款/收款
- TotalPrice: TotalPrice, //合计
- PayType: thisPayType, //现付/预付款
- Remark: $.trim($("#Remark").val()),
- AccountIdList: $("#AccountId").attr("data-accountarr"), //账户列表-多账户
- AccountMoneyList: accountMoneyArr ? JSON.stringify(accountMoneyArr) : "", //账户金额列表-多账户
- Discount: $.trim($("#Discount").val()),
- DiscountMoney: $.trim($("#DiscountMoney").val()),
- DiscountLastMoney: $.trim($("#DiscountLastMoney").val()),
- OtherMoney: $.trim($("#OtherMoney").val()), //采购费用、销售费用
- OtherMoneyList: $("#OtherMoney").attr("data-itemarr"), //支出项目列表-涉及费用
- OtherMoneyItem: $("#OtherMoney").attr("data-itemmoneyarr"), //支出项目金额列表-涉及费用
- AccountDay: $("#AccountDay").val() //结算天数
- });
- /**
- * 零售出库,单独操作
- * */
- if(url.indexOf("/depotHead/addDepotHeadAndDetail")>=0){
- addDepotHeadAndDetail(url,infoStr);
- return;
- }else if(url.indexOf("/depotHead/updateDepotHeadAndDetail")>=0){
- updateDepotHeadAndDetail(url,infoStr,preTotalPrice);
- return;
- }
-
- }
- });
-
- //打印单据
- $("#printDepotHeadShow").off("click").on("click",function(){
- var tableString = $("#depotHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event){
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="State"||obj.id=="Number"))
- {
- $("#saveDepotHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber"||obj.id=="searchMaterial"))
- {
- $("#searchBtn").click();
- }
- });
-
- //优惠率输入框事件
- $("#Discount").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountNum = $(this).val();
- var discountMoney = (discountNum/100*totalPrice).toFixed(2);
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#DiscountMoney").val(discountMoney); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //优惠金额输入框事件
- $("#DiscountMoney").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountMoney = $(this).val();
- var discount = (discountMoney/totalPrice).toFixed(2)*100;
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#Discount").val(discount); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //付款、收款输入框事件
- $("#ChangeAmount").off("keyup").on("keyup",function(){
- var discountLastMoney = $("#DiscountLastMoney").val();
- var changeAmount = $(this).val();
- var debtMoney = (discountLastMoney - changeAmount).toFixed(2);
- $("#Debt").val(debtMoney); //本次欠款
- });
-
- //多账户结算窗口弹出事件
- function depotHeadAccountDlgFun(){
- $('#depotHeadAccountDlg').dialog('open').dialog('setTitle','
多账户结算');
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").remove(); //先移除输入栏目
- $("#accountMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#depotHeadAccountDlg .tabs-tmp .account-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#depotHeadAccountDlg .tabs-tmp tbody").html();
- var accountDlgHead = $("#depotHeadAccountDlg .account-head-tmp");
- accountDlgHead.after(contentTmp);
- }
-
- //获取账户信息
- function accountDlgFun() {
- var options = "";
- if(accountList !=null){
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- }
- $(".account-id-dlg").empty().append("").append(options);
- }
- }
- accountDlgFun(); //获取账户信息
- $("#depotHeadAccountDlg .tabs-tmp").hide(); //隐藏模板
-
- //账户金额输入框事件-多账户
- $("#depotHeadAccountDlg .account-dlg .account-money-dlg").off("keyup").on("keyup",function(){
- var totalAccoutNum = 0;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var eachAccountMoney = $(this).find(".account-money-dlg").val()-0;
- totalAccoutNum += eachAccountMoney;
- });
- $("#accountMoneyTotalDlg").text(totalAccoutNum);
- });
-
- //结算多账户列表的切换事件
- $("#depotHeadAccountDlg .account-dlg .account-id-dlg").off("change").on("change",function(){
- var selectAccount = $(this).children('option:selected').text();
- if(selectAccount === ""){
- var thisMoneyDom = $(this).closest(".account-content-tmp").find(".account-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text() - 0;
- $("#accountMoneyTotalDlg").text(accountMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //账户为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveDepotHeadAccountDlg").off("click").on("click", function(){
- //完成多账户的json数据存储
- var accountArr = []; //账户id数组
- var accountMoneyArr = []; //账户金额数组
- var errorIndex = -1;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var thisAccId = $(this).find(".account-id-dlg").val();
- var thisAccMoney = $(this).find(".account-money-dlg").val();
- if(!thisAccId && thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && !thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && thisAccMoney) {
- accountArr.push(thisAccId);
- accountMoneyArr.push(thisAccMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var discountLastMoneyNum =$("#DiscountLastMoney").val()-0; //优惠后金额
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text()-0; //本次付款或者收款
- if(accountMoneyTotal===0){
- $.messager.alert('错误提示',"请填写金额后保存",'warning');
- return;
- }
- if(accountArr.length && accountMoneyArr.length) {
- $("#AccountId").attr("data-accountArr",JSON.stringify(accountArr)).attr("data-accountMoneyArr",JSON.stringify(accountMoneyArr)); //json数据存储
- }
- $("#ChangeAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
- $("#Debt").val((discountLastMoneyNum-accountMoneyTotal).toFixed(2)); //本次欠款
- $("#depotHeadAccountDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#AccountId").attr("data-accountArr")){
- $("#depotHeadAccountDlg").dialog('close');
- }
- else {
- $("#depotHeadAccountDlg").dialog('close');
- $("#AccountId").val("").removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- }
- //多账户-取消按钮
- $("#cancelDepotHeadAccountDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //多账户-右上角的关闭按钮
- $("#depotHeadAccountDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
- }
- //点击多账户,弹出输入框
- $("#AccountId").off("change").on("change",function(){
- var selectText = $(this).children('option:selected').text();
- if(selectText === "多账户"){
- $("#ChangeAmount").prop("readonly","readonly");
- depotHeadAccountDlgFun();
- $(".many-account-ico").show(); //显示多账户小图标
- }
- else{
- $(this).removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- });
-
- //结算账户-多账户小图标-点击事件
- $(".many-account-ico").off("click").on("click",function(){
- depotHeadAccountDlgFun();
- //给弹窗赋值-多账户数据
- var accountArr = $("#AccountId").attr("data-accountArr");
- accountArr = JSON.parse(accountArr);
- var accountMoneyArr = $("#AccountId").attr("data-accountMoneyArr");
- accountMoneyArr = JSON.parse(accountMoneyArr);
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".account-id-dlg").val(accountArr[index]);
- $(this).find(".account-money-dlg").val(accountMoneyArr[index]);
- });
- $("#accountMoneyTotalDlg").text($("#ChangeAmount").val());
- });
-
- //点击采购费用、销售费用的事件
- $(".other-money-ico").off("click").on("click",function(){
- $('#otherMoneyDlg').dialog('open').dialog('setTitle','
'+ listSubType +'费用');
- $("#otherMoneyDlg .money-dlg .money-content-tmp").remove(); //先移除输入栏目
- $("#otherMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#otherMoneyDlg .tabs-tmp .money-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#otherMoneyDlg .tabs-tmp tbody").html();
- var moneyDlgHead = $("#otherMoneyDlg .money-head-tmp");
- moneyDlgHead.after(contentTmp);
- }
-
- //获取支出项目信息
- function moneyDlgFun() {
- var options = "";
- if(outItemList !=null){
- for(var i = 0 ;i < outItemList.length;i++) {
- var money = outItemList[i];
- options += '';
- }
- $(".money-id-dlg").empty().append("").append(options);
- }
- }
- moneyDlgFun(); //获取支出项目信息
- $("#otherMoneyDlg .tabs-tmp").hide(); //隐藏模板
-
- //支出项目的金额输入框事件
- $("#otherMoneyDlg .money-dlg .other-money-dlg").off("keyup").on("keyup",function(){
- var totalMoneyNum = 0;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var eachOtherMoney = $(this).find(".other-money-dlg").val()-0;
- totalMoneyNum += eachOtherMoney;
- });
- $("#otherMoneyTotalDlg").text(totalMoneyNum);
- });
-
- //支出项目列表的切换事件
- $("#otherMoneyDlg .money-dlg .money-id-dlg").off("change").on("change",function(){
- var selectItem = $(this).children('option:selected').text();
- if(selectItem === ""){
- var thisMoneyDom = $(this).closest(".money-content-tmp").find(".other-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text() - 0;
- $("#otherMoneyTotalDlg").text(otherMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //支出项目为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveOtherMoneyDlg").off("click").on("click", function(){
- //完成支出项目的json数据存储
- var itemArr = []; //支出项目id数组
- var itemMoneyArr = []; //支出项目金额数组
- var errorIndex = -1;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var thisId = $(this).find(".money-id-dlg").val();
- var thisMoney = $(this).find(".other-money-dlg").val();
- if(!thisId && thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && !thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && thisMoney) {
- itemArr.push(thisId);
- itemMoneyArr.push(thisMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text()-0; //合计金额
- if(otherMoneyTotal === 0){ //0的时候清空缓存数据
- $("#OtherMoney").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr");
- }
- if(itemArr.length && itemMoneyArr.length) {
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
- $("#OtherMoney").val(otherMoneyTotal); //给采购费用、销售费用赋值
- $("#otherMoneyDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#OtherMoney").attr("data-itemArr")){
- $("#otherMoneyDlg").dialog('close');
- }
- else {
- $("#otherMoneyDlg").dialog('close');
- $("#OtherMoney").val("").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr"); //将下拉置空并把缓存参数清空
- }
- }
- //费用-取消按钮
- $("#cancelOtherMoneyDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //费用-右上角的关闭按钮
- $("#otherMoneyDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
-
- //给弹窗赋值-采购费用、销售费用数据
- var itemArr = $("#OtherMoney").attr("data-itemArr");
- itemArr = JSON.parse(itemArr);
- var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr");
- itemMoneyArr = JSON.parse(itemMoneyArr);
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".money-id-dlg").val(itemArr[index]);
- if(itemMoneyArr[index]!="undefined"){
- $(this).find(".other-money-dlg").val(itemMoneyArr[index]);
- }
- });
- $("#otherMoneyTotalDlg").text($("#OtherMoney").val());
- });
-
- var supplierType = "客户";
- //检查单位名称是否存在 ++ 重名无法提示问题需要跟进
- function checkSupplierName() {
- var supplierName = $.trim($("#supplier").val());
- var orgSupplier = "";
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(supplierName.length > 0 &&( orgSupplier.length ==0 || supplierName != orgSupplier))
- {
- $.ajax({
- type:"get",
- url: "/supplier/checkIsNameExist",
- dataType: "json",
- async : false,
- data: ({
- id : 0,
- name : supplierName
- }),
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data && res.data.status) {
- flag = res.data.status;
- if (flag) {
- $.messager.alert('提示', '单位名称已经存在', 'info');
- return;
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('提示','检查单位名称是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
-
- //保存供应商信息
- $("#saveSupplier").off("click").on("click",function() {
- if(validateForm("supplierFM")) {
- return;
- }
- if(checkSupplierName()){
- return;
- }
- var reg = /^([0-9])+$/;
- var phonenum = $.trim($("#phonenum").val());
- if(phonenum.length>0 && !reg.test(phonenum))
- {
- $.messager.alert('提示','电话号码只能是数字','info');
- $("#phonenum").val("").focus();
- return;
- }
- var beginNeedGet = $.trim($("#BeginNeedGet").val());
- var beginNeedPay = $.trim($("#BeginNeedPay").val());
- if(beginNeedGet && beginNeedPay) {
- $.messager.alert('提示','期初应收和期初应付不能同时输入','info');
- return;
- }
- var url = '/supplier/add';
- var supObj = $("#supplierFM").serializeObject();
- supObj.type = supplierType;
- supObj.enabled = 1;
- $.ajax({
- url: url,
- type:"post",
- dataType: "json",
- data:{
- info: JSON.stringify(supObj)
- },
- success: function(res) {
- if (res) {
- $('#supplierDlg').dialog('close');
- initSupplier(); //刷新供应商
- }
- }
- });
- });
-}
-
-function showDepotHeadDetails(pageNo,pageSize){
- var materialParam = $.trim($("#searchMaterial").val());
- var beginTime = $.trim($("#searchBeginTime").val());
- var endTime = $.trim($("#searchEndTime").val());
- if(beginTime) {
- beginTime = beginTime + ' 00:00:00';
- }
- if(endTime) {
- endTime = endTime + ' 23:59:59';
- }
- $.ajax({
- type: "get",
- url: "/depotHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- subType: listSubType,
- state: $.trim($("#searchState").val()),
- number: $.trim($("#searchNumber").val()),
- beginTime: beginTime,
- endTime: endTime,
- materialParam: materialParam,
- depotIds: depotString
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#depotHeadFM .datagrid-body");
- var footer =$("#depotHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
- //点击商品下拉框,自动加载数量、单价、金额
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //点击库存文本框,字段计算库存
- body.find("[field='Stock']").find(input).off("click").on("click",function(){
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- var monthTime = getNowFormatMonth();
- if(depotId && mId){
- var ratio = body.find("[field='Unit']").find(input).attr("data-ratio");
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //在新增的时候,这个ratio有值;在编辑的时候,这个ratio为undefined
- var type = "click"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratio, type);
- }
- else{
- body.find("[field='Stock']").find(input).val(0).attr("data-stock",0); //加载库存数据
- }
- });
- //修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计
- body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber =$(this).val()-0; //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
-
- });
- //修改单价,自动计算金额和合计
- body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice =$(this).val()-0; //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击单价,自动提示参考价格列表
- body.find("[field='UnitPrice']").find(input).off("click").on("click",function(){
- var self = this;
- var mValue = body.find("[field='MaterialId'] .combo-value").attr("value"); //获取选中的商品id
- if(!mValue) {
- return;
- }
- else {
- return;
- }
- });
- //修改含税单价,自动计算单价、金额、税额、价税合计和合计
- body.find("[field='TaxUnitPrice']").find(input).off("keyup").on("keyup",function(){
- var TaxUnitPrice =$(this).val()-0; //含税单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var UnitPrice = TaxUnitPrice/(1+taxRate/100); //计算单价
- body.find("[field='UnitPrice']").find(input).val((UnitPrice).toFixed(2)); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改金额,自动计算单价、税额、价税合计和合计
- body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var AllPrice =$(this).val()-0; //金额
- var UnitPrice = (AllPrice/OperNumber).toFixed(2);
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税率,自动计算含税单价、税额、价税合计和合计
- body.find("[field='TaxRate']").find(input).off("keyup").on("keyup",function(){
- var taxRate =$(this).val()-0; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税额,自动计算税率、含税单价、价税合计和合计
- body.find("[field='TaxMoney']").find(input).off("keyup").on("keyup",function(){
- var taxMoney =$(this).val()-0; //税额
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = taxMoney/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改价税合计,自动计算税率、含税单价、税额和合计
- body.find("[field='TaxLastMoney']").find(input).off("keyup").on("keyup",function(){
- var taxLastMoney =$(this).val()-0; //价税合计
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = (taxLastMoney-AllPrice)/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
-
- //加载税率
- if(thisTaxRate) {
- body.find("[field='TaxRate']").find(input).val(thisTaxRate);
- }
- else {
- body.find("[field='TaxRate']").find(input).val(0); //默认为0
- }
-
- //在商品类型加载 组装件、普通子件
- var mType = body.find("[field='MType']");
- var rowListLength = mType.find(input).closest(".datagrid-row").attr("datagrid-row-index");
- var mTypeValue = "组合件";
- if(rowListLength > 0){
- mTypeValue = "普通子件";
- }
- },500);
-}
-
-//结束编辑
-function endEditing() {
- if (editIndex == undefined) { return true }
- if ($('#materialData').datagrid('validateRow', editIndex)) {
- //仓库信息
- var edDepot = $('#materialData').datagrid('getEditor', {index:editIndex,field:'DepotId'});
- var DepotName = $(edDepot.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName;
- //商品信息
- var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'});
- var MaterialName = $(edMaterial.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName;
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#materialData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append(){
- if (endEditing()) {
- $('#materialData').datagrid('appendRow', {DepotId:defDepotId});
- editIndex = $('#materialData').datagrid('getRows').length - 1;
- $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function batchDel(){
- /**
- * 重写一下删除的逻辑
- * 获取所有选中行,直接从列表中移除
- * 点击保存时,将需要后台删除的数据提交到服务器
- * **/
- /**
- * create by: qiankunpingtai
- * create time: 2019/3/20 16:26
- * description:
- * 这个地方比较坑的,花了一个多小时才搞明白为什么
- * 1、删除之前必须先调用endEditing结束编辑
- * 2、如果只是调用endEditing结束编辑那么正在编辑行的被选中状态会被去掉
- * 所以要在调用endEditing先获取选中的行
- */
- //如果编辑的行一开始是选中状态,结束编辑后仍然是选中状态
- var row = $('#materialData').datagrid('getChecked');
- if (endEditing()) {
- if (row.length == 0) {
- $.messager.alert('删除提示', '没有记录被选中!', 'info');
- return;
- }
- if (row.length > 0) {
- $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条单据信息吗?', function (r) {
- if (r) {
- for (var i = 0; i < row.length; i++) {
- $('#materialData').datagrid('deleteRow', $('#materialData').datagrid("getRowIndex", row[i]));
- }
- }
- });
- }
- }
-}
-function removeit(){
- if (editIndex == undefined) { return }
- $('#materialData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#materialData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData(type) {
- var change = $('#materialData').datagrid('getChanges').length;
- if(type =="add" && !change) {
- $.messager.alert('提示','请输入明细信息!','warning');
- return false;
- }
- var row = $('#materialData').datagrid('getRows');
- if(!row.length){
- $.messager.alert('提示',"请输入明细信息!",'info');
- return false;
- }
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if (row[i].DepotId == "" || row[i].MaterialId == "" || row[i].OperNumber == "" || row[i].UnitPrice === "" || row[i].AllPrice === "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-
-/**
- * 新增单据主表及单据子表
- * */
-function addDepotHeadAndDetail(url,infoStr){
- var inserted = null;
- if(pageType === "skip") {
- inserted = $("#materialData").datagrid('getChanges', "updated");
- } else {
- inserted = $("#materialData").datagrid('getChanges', "inserted");
- }
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated)
- }),
- success: function (tipInfo){
-
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
-
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
-
-
- });
-}
-/**
- * 修改单据主表及单据子表
- * */
-function updateDepotHeadAndDetail(url,infoStr,preTotalPrice){
- var inserted = $("#materialData").datagrid('getChanges', "inserted");
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- id:url.substring(url.lastIndexOf("?id=")+4,url.length),
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- preTotalPrice:preTotalPrice
- }),
- success: function (tipInfo){
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
- if (endEditing()) {
- $('#materialData').datagrid('acceptChanges');
- }
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-
-
-
diff --git a/erp_web/js/pages/materials/sale_out_list.js b/erp_web/js/pages/materials/sale_out_list.js
deleted file mode 100644
index 8935b686..00000000
--- a/erp_web/js/pages/materials/sale_out_list.js
+++ /dev/null
@@ -1,2534 +0,0 @@
-//初始化界面
-var defDepotId = null;
-var kid = sessionStorage.getItem("userId");
-var pageType = getUrlParam('t'); //获取页面类型传值
-var depotList = null;
-var depotID = null;
-var supplierList = null;
-var supplierID = null;
-var personList = null;
-var personID = null;
-var ProjectSearch=null;
-var userBusinessList=null;
-var userdepot=null;
-var url;
-var depotHeadID = 0;
-var preTotalPrice = 0; //前一次加载的金额
-var orgDepotHead = "";
-var editIndex = undefined;
-/**默认编号有意义吗,不如空着吧*/
-var orgDefaultId=''; //单位默认编号
-var orgDefaultList; //存储查询出来的会员列表
-var accountList; //账户列表
-var outItemList; //支出项目列表
-var thisTaxRate = 0; //当前税率,选择供应商或者客户的时候设置
-var oldNumber = ""; //编辑前的单据编号
-var oldId = 0; //编辑前的单据Id
-var otherColumns = true; //明细中的‘别名’列是否显示
-var btnEnableList = getBtnStr(); //获取按钮的权限
-var mPropertyList = ""; //商品属性列表
-var defaultAccountId = 0; //默认账户id
-//改变宽度和高度
-$("#searchPanel").panel({width:webW-2});
-$("#tablePanel").panel({width:webW-2});
-var listTitle = "销售出库列表"; //单据标题
-var depotString = "|"; //店铺id列表
-var listType ="出库";//入库 出库
-var listSubType ="销售";//采购 销售等
-var payTypeTitle = "收款";//付款 收款
-var organUrl ="/supplier/findBySelect_cus?UBType=UserCustomer&UBKeyId=" + kid;//组织数据接口地址
-var amountNum ="XSCK";//单据编号开头字符
-$(function(){
- //初始化系统基础信息
- initSystemData_UB();
- initSelectInfo_UB();
- initSystemData_depot();
- initSelectInfo_depot();
- initSystemData_person();
- initSelectInfo_person();
- initSystemData_account();
- initSelectInfo_account();
- initSupplier(); //供应商
- initSalesman(); //销售人员
- initOutItemList(); //初始化支出项目
- initMProperty(); //初始化商品属性
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
-});
-//初始化系统基础信息
-function initSystemData_UB(){
- $.ajax({
- type:"get",
- url: "/userBusiness/getBasicData",
- data: ({
- KeyId:kid,
- Type:"UserDepot"
- }),
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if (res && res.code === 200) {
- userBusinessList = res.data.userBusinessList;
- }
- else {
- userBusinessList = null;
- }
- }
- });
-
-}
-//初始化页面选项卡
-function initSelectInfo_UB(){
-
- if(userBusinessList !=null)
- {
- if(userBusinessList.length>0)
- {
- //用户对应的仓库列表 [1][2][3]...
- userdepot =userBusinessList[0].value;
- }
- }
-}
-
-
-//初始化系统基础信息
-function initSystemData_depot(){
- $.ajax({
- type:"get",
- url: "/depot/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200){
- depotList = res.data;
- } else {
- $.messager.alert('提示', '查找系统基础信息异常,请与管理员联系!', 'error');
- return;
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_depot(){
- var options = "";
-
- if(depotList !=null)
- {
- options = "";
- for(var i = 0 ;i < depotList.length;i++)
- {
- var depot = depotList[i];
-
- if(userdepot!=null)
- {
- if(userdepot.indexOf("["+depot.id+"]")!=-1)
- {
- if(depot.isDefault){
- defDepotId = depot.id;
- }
- options += '';
- depotString = depotString + depot.id + ",";
- }
- }
- if(depot.type === 1){
- depotString = depotString + depot.id + ",";
- }
- }
- depotString = depotString.substring(1, depotString.length-1);
- $("#ProjectId").empty().append(options);
- $("#AllocationProjectId").empty().append(options);
- $("#searchProjectId").empty().append('').append(options);
- }
-}
-
-//初始化供应商、客户、散户信息
-function initSupplier(){
- $('#OrganId').combobox({
- url: organUrl,
- valueField:'id',
- textField:'supplier',
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onLoadSuccess: function(res) {
- var data = $(this).combobox('getData');
- for(var i = 0; i<= data.length; i++){
- if(data && data[i] && data[i].supplier === "非会员"){
- orgDefaultId = data[i].id;
- }
- }
- },
- onSelect: function(rec){
- $.ajax({
- type:"get",
- url: "/supplier/findById",
- data: {
- supplierId: rec.id
- },
- dataType: "json",
- success: function (res){
- if(res && res.code === 200) {
- if(res.data && res.data[0]){
- thisTaxRate = res.data[0].taxRate; //设置当前的税率
- }
- }
- },
- error:function(){
-
- }
- });
- }
- });
-}
-
-//初始化销售人员
-function initSalesman(){
- $('#Salesman').combobox({
- url: "/person/getPersonByNumType?type=1",
- valueField:'id',
- textField:'name',
- multiple: true
- });
-}
-
-//初始化收入项目列表
-function initOutItemList(){
- $.ajax({
- type:"get",
- url: "/inOutItem/findBySelect?type=out",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res){
- if(res){
- outItemList = res;
- }
- },
- error:function(){
-
- }
- });
-}
-
-//初始化商品属性
-function initMProperty(){
- $.ajax({
- type: "get",
- url: "/materialProperty/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- name: ""
- }),
- currentPage: 1,
- pageSize: 100
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- var thisRows = res.data.page.rows;
- for (var i = 0; i < thisRows.length; i++) {
- if (thisRows[i].enabled) {
- mPropertyList += thisRows[i].nativename + ",";
- }
- }
- if (mPropertyList) {
- mPropertyList = mPropertyList.substring(0, mPropertyList.length - 1);
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('查询提示','查询信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//初始化系统基础信息
-function initSystemData_person(){
- $.ajax({
- type:"get",
- url: "/person/getAllList",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- personList = res.data.personList;
- }
- }
- }
- });
-}
-//初始化页面选项卡
-function initSelectInfo_person(){
- var options1 = "";
-
- if(personList !=null)
- {
- for(var i = 0 ;i < personList.length;i++)
- {
- var person = personList[i];
- if(0 == i)
- {
- personID = person.id;
- }
- if(person.type=="仓管员")
- {
- options1 += '';
- }
- }
- $("#HandsPersonId").empty().append(options1);
- }
-}
-//获取账户信息
-function initSystemData_account(){
- $.ajax({
- type:"get",
- url: "/account/getAccount",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- accountList = res.data.accountList;
- }
- }
- }
- });
-}
-//获取账户信息
-function initSelectInfo_account(){
- var options = "";
- if(accountList !=null){
- options = "";
- options += "";
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- if(account.isdefault) {
- defaultAccountId = account.id; //给账户赋值默认id
- }
- }
- $("#AccountId").empty().append(options);
- }
-}
-
-//防止表单提交重复
-function initForm(){
- $('#depotHeadFM').form({
- onSubmit: function(){
- return false;
- }
- });
-}
-
-//初始化表格数据
-function initTableData(){
- if(pageType === "skip") {
- var oldRowInfo = sessionStorage.getItem("rowInfo");
- editDepotHead(oldRowInfo); //自动弹出编辑框,带缓存数据
- }
- var hideType = undefined;
- var isHiddenStatus = true;
- if(payTypeTitle === "隐藏"){
- hideType = true; //隐藏当前列
- }
- var tableToolBar = [
- {
- id:'addDepotHead',
- text:'增加',
- iconCls:'icon-add',
- handler:function()
- {
- addDepotHead();
- }
- },
- {
- id:'deleteDepotHead',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batDeleteDepotHead();
- }
- }
- ];
- //如果允许的按钮列表中存在就显示,3-代表审核|反审核的权限
- if(btnEnableList && btnEnableList.indexOf(3)>-1){
- isHiddenStatus = false; //显示
- tableToolBar.push({
- id:'okDepotHead',
- text:'审核',
- iconCls:'icon-ok',
- handler:function() {
- setStatusFun();
- }
- },
- {
- id:'undoDepotHead',
- text:'反审核',
- iconCls:'icon-undo',
- handler:function() {
- setUnStatusFun();
- }
- });
- }
- else {
- isHiddenStatus = true; //隐藏
- }
- var isShowLastMoneyColumn = false; //是否显示优惠后金额和价税合计,true为隐藏,false为显示
- var isShowOrganNameColumn = false; //是否显示供应商、客户等信息,true为隐藏,false为显示
- var organNameTitle = "客户名称";//组织名称标题
- var opWidth = 90; //操作宽度
- var opTitle = ""; //跳转按钮的标题
- $('#tableData').datagrid({
- height:heightInfo,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: true,
- //交替出现背景
- striped : true,
- pageSize: 10,
- pageList: initPageNum,
- columns:[[
- { field: 'id',width:35,align:"center",checkbox:true},
- { title: '操作',field: 'op',align:"center",width:opWidth,
- formatter:function(value, rec,index) {
- var str = '';
- var orgId = rec.organid? rec.organid:0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
- { title: '单据编号',field: 'number',width:135, formatter:function (value,rec) {
- if(rec.linknumber) {
- return value + "[转]";
- } else {
- return value;
- }
- }
- },
- { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
- if(value) {
- return value.replace(",",",");
- }
- }
- },
- { title: '单据日期',field: 'opertimeStr',width:130},
- { title: '操作员',field: 'operpersonname',width:60},
- { title: '金额合计',field: 'totalprice',width:60},
- { title: '含税合计',field: 'totaltaxlastmoney',hidden:isShowLastMoneyColumn,width:60,formatter:function(value,rec){
- return (rec.discountmoney + rec.discountlastmoney).toFixed(2);
- }
- },
- { title: '优惠后金额',field: 'discountlastmoney',hidden:isShowLastMoneyColumn,width:80},
- { title: payTypeTitle,field: 'changeamount',width:50,hidden:hideType},
- { title: '状态',field: 'status',hidden:isHiddenStatus, width:70,align:"center",formatter:function(value){
- if(value === "0") {
- return "未审核";
- } else if(value === "1") {
- return "已审核";
- } else if(value === "2") {
- }
- }
- }
- ]],
- toolbar:tableToolBar,
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-//查找库存的方法
-function findStockNumById(depotId, mId, monthTime, body, input, ratio, type){
- var thisRatio = 1; //比例
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (rec) {
- if(rec && rec.code === 200 && rec.data && rec.data[0]) {
- var loadRatio = 1; //在单位输入框上面加载比例字段
- if(rec.data[0].unit) { //如果存在计量单位信息
- loadRatio = 1;
- }
- else{
- var unitName = rec.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- thisRatio = unitName.substring(unitName.indexOf(":")+1).replace(")","");
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- unitSetInput = rec.data[0].firstoutunit;
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = thisRatio;
- }
- }
- //查询库存
- $.ajax({
- type: "get",
- url: '/depotItem/findStockNumById',
- data:{
- projectId: depotId,
- materialId: mId
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if (res.data && res.data.page && res.data.page[0]) {
- var thisStock = res.data.page[0].thisSum;
- if (type == "select") { //选择下拉框的时候
- if (ratio != undefined && ratio != 1) {
- loadRatio = ratio;
- }
- }
- else if (type == "click") { //点击库存的时候
- if (ratio != undefined) {
- loadRatio = ratio;
- }
- }
- thisStock = (thisStock / loadRatio).toFixed(2);
- body.find("[field='Stock']").find(input).val(thisStock).attr("data-stock", res.data.page[0].thisSum); //加载库存数据
- }
- else {
- body.find("[field='Stock']").find(input).val(0).attr("data-stock", 0); //加载库存数据
- }
- body.find("[field='Stock']").find(input).prop("readonly", "readonly"); //设置库存数据为只读
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
- }
- },
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- }
- });
-}
-//优惠率、合计的统计方法
-function statisticsFun(body,UnitPrice,OperNumber,footer,taxRate){
- var TotalPrice = 0;
- var taxLastMoneyTotal = 0;
- //金额的合计
- body.find("[field='AllPrice']").each(function(){
- if($(this).find("div").text()!==""){
- TotalPrice = TotalPrice + parseFloat($(this).find("div").text().toString());
- }
- });
- TotalPrice = TotalPrice + UnitPrice*OperNumber;
- footer.find("[field='AllPrice']").find("div").text((TotalPrice).toFixed(2)); //金额的合计
- //价税合计的总计
- body.find("[field='TaxLastMoney']").each(function(){
- if($(this).find("div").text()!==""){
- taxLastMoneyTotal = taxLastMoneyTotal + (parseFloat($(this).find("div").text().toString())-0);
- }
- });
- taxLastMoneyTotal = taxLastMoneyTotal + (UnitPrice*OperNumber*(1+taxRate/100));
- footer.find("[field='TaxLastMoney']").find("div").text((taxLastMoneyTotal).toFixed(2)); //价税合计的页脚总计
- var discount = $("#Discount").val(); //优惠率
- var discountMoney = (taxLastMoneyTotal*discount/100).toFixed(2);
- $("#DiscountMoney").val(discountMoney);//优惠金额
- var discountLastMoney = (taxLastMoneyTotal*(1-discount/100)).toFixed(2)
- $("#DiscountLastMoney").val(discountLastMoney);//优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
-
-}
-//初始化表格数据-商品列表-编辑状态
-function initTableData_material(type,TotalPrice){
- var body,footer,input; //定义表格和文本框
- var ratio = 1; //比例-品名专用
- var ratioDepot = 1; //比例-仓库用
- var monthTime = getNowFormatMonth();
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var depotHeadName = ""; //仓库名称
- var depotUrl = ""; //仓库接口地址
- var depotTextField = ""; //仓库下拉名称
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var anotherDepotUrl = ""; //对方仓库接口地址
- var anotherDepotTextField = "";
- depotHeadName = "仓库名称";
- depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- depotTextField = "depotName";
- var isShowTaxColumn = false; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialData').datagrid({
- height:245,
- rownumbers: false,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- //单击行是否选中
- checkOnSelect : false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- //loadFilter: pagerFilter,
- onClickRow: onClickRow,
- columns:[[
- { field: 'Id',width:35,align:"center",checkbox:true},
- { title: '商品类型',field: 'MType',editor:'validatebox',hidden:isShowMaterialTypeColumn,width:80},
- { title: depotHeadName, field: 'DepotId', editor: 'validatebox', width: 90,
- formatter: function (value, row, index) {
- return row.DepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: depotTextField,
- method: 'get',
- url: depotUrl,
- onSelect:function(rec){
- var depotId = rec.id;
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- if(mId){
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratioDepot, type);
- }
- }
- }
- }
- },
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialId',width:230,
- formatter:function(value,row,index){
- return row.MaterialName;
- },
- editor:{
- type:'combobox',
- options:{
- valueField:'Id',
- textField:'MaterialName',
- method:'get',
- url: "/material/findBySelect",
- panelWidth: 300, //下拉框的宽度
- //全面模糊匹配,过滤字段
- filter: function(q, row){
- var opts = $(this).combobox('options');
- return row[opts.textField].indexOf(q) >-1;
- },
- onBeforeLoad: function(param){
- param.mpList = mPropertyList; //商品属性
- },
- onSelect:function(rec){
- if(rec) {
- var mId = rec.Id;
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mId
- },
- success: function (res) {
- if(res && res.code === 200 && res.data && res.data[0]) {
- var retailPrice = res.data[0].retailprice-0; //零售价格
- var presetPriceOne = res.data[0].presetpriceone-0; //预计采购价
- var presetPriceTwo = res.data[0].presetpricetwo-0; //批发价
- var firstInUnit = res.data[0].firstinunit; //首选入库单位
- var firstOutUnit = res.data[0].firstoutunit; //首选出库单位
- var basicPresetPriceOne = ""; //多单位-入库-基础价格
- var basicPresetPriceTwo = ""; //多单位-出库-基础价格
- var retailPriceOne = ""; //多单位-入库-零售价格
- var otherPresetPriceOne = ""; //多单位-入库-其他价格
- var otherPresetPriceTwo = ""; //多单位-出库-其他价格
- var retailPriceTwo = ""; //多单位-出库-零售价格
- var basicUnit = ""; //基础单位
- var otherUnit = ""; //其他单位
- if(!res.data[0].unit){
- var ps = res.data[0].pricestrategy;
- var psObj = JSON.parse(ps);
- basicPresetPriceOne = psObj[0].basic.PresetPriceOne-0;
- basicPresetPriceTwo = psObj[0].basic.PresetPriceTwo-0;
- retailPriceOne = psObj[0].basic.RetailPrice-0;
- otherPresetPriceOne = psObj[1].other.PresetPriceOne-0;
- otherPresetPriceTwo = psObj[1].other.PresetPriceTwo-0;
- retailPriceTwo = psObj[1].other.RetailPrice-0;
- basicUnit = psObj[0].basic.Unit;
- otherUnit = psObj[1].other.Unit;
- }
- body =$("#depotHeadFM .datagrid-body");
- footer =$("#depotHeadFM .datagrid-footer");
- input = ".datagrid-editable-input";
- if(res.data[0].unit){ //如果存在计量单位信息
- ratio = 1; //重置比例为1
- body.find("[field='Unit']").find(input).val(res.data[0].unit); //设置-计量单位信息
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- body.find("[field='Unit']").find(input).off("click"); //移除点击事件
- body.find("[field='Unit']").find(input).attr("data-ratio",ratio); //修改比例缓存信息
- }
- else {
- var unitName = res.data[0].unitName;
- var basicUnit="";
- var otherUnit="";
- if(unitName) {
- ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
- unitName = unitName.substring(0, unitName.indexOf("("));
- var unitArr = unitName.split(",");
- basicUnit = unitArr[0]; //基础单位
- otherUnit = unitArr[1]; //副单位
- }
- var unitSetInput =""; //单位
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- var loadRatio = 1; //在单位输入框上面加载比例字段
- unitSetInput = res.data[0].firstoutunit; //给单位文本框赋值
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = ratio;
- }
- body.find("[field='Unit']").find(input).val(unitSetInput).attr("data-ratio", loadRatio); //设置-首选单位
-
- body.find("[field='Unit']").find(input).off("click").on("click",function(){
- if(basicUnit && otherUnit) {
- var self = this;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- " + basicUnit + "
";
- temp +="- " + otherUnit + "
";
- temp +="
";
- temp +="
";
- if($('.unit-list').length){
- $('.unit-list').remove(); //如果存在计量单位列表先移除
- }
- else {
- $(self).after(temp); //加载列表信息
- }
- //计量单位列表的单击事件
- $('.unit-list ul li').off("click").on("click",function(){
- var unit = $(this).text();
- var thisRatio = $(this).attr("data-ratio"); //获取比例
- $(self).val(unit).attr("data-ratio", thisRatio);
- $(self).keyup(); //模拟键盘操作
- $('.unit-list').remove(); //移除计量单位列表
- var stock = body.find("[field='Stock']").find(input).attr("data-stock"); //从缓存中取值
- var type = $(this).attr("data-type");
- var UnitPrice = 0;
- if(type === "basic"){
- UnitPrice = basicPresetPriceTwo;
- body.find("[field='Stock']").find(input).val(stock); //修改库存
- }
- else if(type === "other"){
- UnitPrice = otherPresetPriceTwo;
- body.find("[field='Stock']").find(input).val((stock/ratio).toFixed(2)); //修改库存
- }
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //获取数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击空白处移除计量单位列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.unit-list').remove(); //移除计量单位列表
- });
- }
- });
- }
- var detailPrice = 0; //明细列表-单价
- if(res.data[0].unit) { //如果存在计量单位信息
- detailPrice = presetPriceTwo;
- }
- else {
- if(firstOutUnit==basicUnit) {
- detailPrice = basicPresetPriceTwo;
- }
- else if(firstOutUnit==otherUnit){
- detailPrice = otherPresetPriceTwo;
- }
- }
- body.find("[field='OperNumber']").find(input).val(1); //数量初始化为1
- //单价和总价赋值
- if(!detailPrice) {
- detailPrice = 0;
- }
- body.find("[field='UnitPrice']").find(input).val(detailPrice);
- body.find("[field='AllPrice']").find(input).val(detailPrice);
- var taxRate = body.find("[field='TaxRate']").find(input).val()-0; //获取税率
- body.find("[field='TaxUnitPrice']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((detailPrice*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((detailPrice*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,detailPrice,1,footer,taxRate);
-
- //查询库存信息
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- if(depotId) {
- var type = "select"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, loadRatio, type);
- }
- }
- },
- error: function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- }
- });
- }
- }
- }
- }
- },
- { title: '库存',field: 'Stock',editor:'validatebox',width:70},
- { title: anotherDepotHeadName, field: 'AnotherDepotId',editor:'validatebox',hidden:isShowAnotherDepot,width:90,
- formatter: function (value, row, index) {
- return row.AnotherDepotName;
- },
- editor: {
- type: 'combobox',
- options: {
- valueField: 'id',
- textField: anotherDepotTextField,
- method: 'get',
- url: anotherDepotUrl
- }
- }
- },
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率(%)',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- toolbar:[
- {
- id:'append',
- text:'新增',
- iconCls:'icon-add',
- handler:function()
- {
- append(); //新增
- }
- },
- {
- id:'delete',
- text:'删除',
- iconCls:'icon-remove',
- handler:function()
- {
- batchDel(); //删除
- }
- },
- {
- id:'reject',
- text:'撤销',
- iconCls:'icon-undo',
- handler:function()
- {
- reject(); //撤销
- }
- }
- ],
- onLoadError:function()
- {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = 0;
- var TaxLastMoney = 0;
- var DiscountMoney = $("#DiscountMoney").val()-0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoney").val()-0; //优惠后金额
- if(type === "edit") {
- AllPrice = TotalPrice;
- TaxLastMoney = DiscountMoney + DiscountLastMoney;
- }
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": TaxLastMoney
- });
- data.footer = array;
- $("#materialData").datagrid('loadData',data);
- //如果是订单跳转到采购或销售
- if(pageType === "skip") {
- var skipList = $("#depotHeadFM .datagrid-body tr");
- //逐条自动点击每行数据
- skipList.each(function (i) {
- setTimeout(function () {
- skipList.eq(i).find("[field='Stock']").click();
- },(i+1)*1000);
- });
- }
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//初始化表格数据-商品列表-查看状态
-function initTableData_material_show(TotalPrice){
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var depotHeadName = ""; //仓库的列的标题
- depotHeadName = "仓库名称";
- var isShowTaxColumn = false; //是否显示税率相关的列,true为隐藏,false为显示
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- $('#materialDataShow').datagrid({
- height:245,
- rownumbers: true,
- //动画效果
- animate:false,
- //选中单行
- singleSelect : true,
- collapsible:false,
- selectOnCheck:false,
- pagination: false,
- //交替出现背景
- striped : true,
- showFooter: true,
- onClickRow: onClickRow,
- columns:[[
- { title: '商品类型',field: 'MType',width:80, hidden:isShowMaterialTypeColumn},
- { title: depotHeadName,field: 'DepotName',editor:'validatebox',width:90},
- { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialName',width:230},
- { title: anotherDepotHeadName,field: 'AnotherDepotName',hidden:isShowAnotherDepot,width:90},
- { title: '单位',field: 'Unit',editor:'validatebox',width:60},
- { title: '数量',field: 'OperNumber',editor:'validatebox',width:60},
- { title: '单价',field: 'UnitPrice',editor:'validatebox',width:60},
- { title: '含税单价',field: 'TaxUnitPrice',editor:'validattebox',hidden:isShowTaxColumn,width:75},
- { title: '金额',field: 'AllPrice',editor:'validatebox',width:75},
- { title: '税率',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75},
- { title: '备注',field: 'Remark',editor:'validatebox',width:120},
- { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60},
- { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60},
- { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60}
- ]],
- onLoadError:function() {
- $.messager.alert('页面加载提示','页面加载异常,请稍后再试!','error');
- return;
- }
- });
- $.ajax({
- type:"get",
- url: '/depotItem/getDetailList',
- data: {
- headerId: depotHeadID,
- mpList: mPropertyList
- },
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- var data = res.data;
- var AllPrice = TotalPrice;
- var DiscountMoney = $("#DiscountMoneyShow").text() - 0; //优惠金额
- var DiscountLastMoney = $("#DiscountLastMoneyShow").text() - 0; //优惠后金额
- var array = [];
- array.push({
- "AllPrice": AllPrice,
- "TaxLastMoney": DiscountMoney + DiscountLastMoney
- });
- data.footer = array;
- $("#materialDataShow").datagrid('loadData', data);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
-}
-
-//分页信息处理
-function ininPager(){
- try
- {
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- pager.pagination({
- onSelectPage:function(pageNum, pageSize)
- {
- opts.pageNumber = pageNum;
- opts.pageSize = pageSize;
- pager.pagination('refresh',
- {
- pageNumber:pageNum,
- pageSize:pageSize
- });
- showDepotHeadDetails(pageNum,pageSize);
- }
- });
- }
- catch (e)
- {
- $.messager.alert('异常处理提示',"分页信息异常 : " + e.name + ": " + e.message,'error');
- }
-}
-
-//删除单据信息
-function deleteDepotHead(depotHeadID, thisOrganId, totalPrice, status){
- if(status == "1" || status == "2") {
- $.messager.alert('删除提示','已审核和已转的单据不能删除!','warning');
- return;
- }
- $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
- if (r) {
- $.ajax({
- type:"post",
- // url: "/depotHead/" + depotHeadID + "/delete",
- url: "/depotHead/deleteDepotHeadAndDetail",
- dataType: "json",
- data:{
- id: depotHeadID
- },
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('删除提示','删除单据信息异常,请稍后再试!','error');
- return;
- }
- });
-
- }
- });
-}
-
-//订单转采购或销售
-function skipDepotHead(index, status){
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- if(status == "0" || status == "2") {
- $.messager.alert('提示','未审核和已转的单据禁止操作!','warning');
- } else {
- sessionStorage.setItem("rowInfo", JSON.stringify(rowsdata)); //将单据信息存入缓存中
- }
-}
-
-//批量删除单据信息
-function batDeleteDepotHead(){
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('删除提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('删除确认','确定要删除选中的' + row.length + '条单据信息吗?',function(r)
- {
- if (r) {
- var ids = "";
- for (var i = 0; i < row.length; i++) {
- if (i == row.length - 1) {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- if (ids) {
- //批量删除
- $.ajax({
- type: "post",
- // url: "/depotHead/batchDelete",
- url: "/depotHead/batchDeleteDepotHeadAndDetail",
- dataType: "json",
- async: false,
- data: ({
- ids: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('删除提示', '删除单据信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('删除提示', '删除单据信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('删除提示','没有能删除的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量审核
-function setStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0) {
- $.messager.alert('审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0) {
- $.messager.confirm('审核确认','确定要审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: "1",
- depotHeadIDs : ids
- }),
- success: function (res) {
- if(res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('审核提示', '审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('审核提示','审核信息异常,请稍后再试!','error');
- return;
- }
- });
- } else {
- $.messager.alert('审核提示','没有能审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//批量反审核
-function setUnStatusFun() {
- var row = $('#tableData').datagrid('getChecked');
- if(row.length == 0)
- {
- $.messager.alert('反审核提示','没有记录被选中!','info');
- return;
- }
- if(row.length > 0)
- {
- $.messager.confirm('反审核确认','确定要反审核选中的' + row.length + '条信息吗?',function(r)
- {
- if (r)
- {
- var ids = "";
- for(var i = 0;i < row.length; i ++)
- {
- if(i == row.length-1)
- {
- if(row[i].status != "2") {
- ids += row[i].id;
- }
- break;
- }
- ids += row[i].id + ",";
- }
- if(ids) {
- $.ajax({
- type: "post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async: false,
- data: ({
- status: "0",
- depotHeadIDs: ids
- }),
- success: function (res) {
- if (res && res.code === 200) {
- $("#searchBtn").click();
- $(":checkbox").attr("checked", false);
- } else {
- $.messager.alert('反审核提示', '反审核信息失败,请稍后再试!', 'error');
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('反审核提示', '反审核信息异常,请稍后再试!', 'error');
- return;
- }
- });
- } else {
- $.messager.alert('反审核提示','没有能反审核的单据!','warning');
- }
- }
- });
- }
-}
-
-//生成单据编号
-function buildNumber() {
- $.ajax({
- type: "get",
- url: "/depotHead/buildNumber",
- success:function(res){
- if(res && res.code === 200){
- var obj = res.data;
- var defaultNumber = obj.DefaultNumber;
- var newNumber = amountNum + defaultNumber;
- $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
- }
- },
- error:function(){
- $.messager.alert('提示','生成单据编号失败!','error');
- }
- });
-}
-
-//新增信息
-function addDepotHead(){
- $('#depotHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- buildNumber(); //生成单据编号
- //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为0
- $("#Discount").val(0);
- $("#DiscountMoney").val(0);
- $("#DiscountLastMoney").val(0);
- $("#ChangeAmount").val(0);
- $("#Debt").val(0);
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- var addTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
增加' + addTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- orgDepotHead = "";
- depotHeadID = 0;
- initTableData_material("add"); //商品列表
- reject(); //撤销下、刷新商品列表
- $("#addOrgan").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加供应商信息');
- $('#supplierFM').form('clear');
- });
-
- $("#addMember").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加会员信息');
- $('#supplierFM').form('clear');
- });
- $("#addCustomer").off("click").on("click",function(){
- $('#supplierDlg').dialog('open').dialog('setTitle','
增加客户信息');
- $('#supplierFM').form('clear');
- });
- url = '/depotHead/addDepotHeadAndDetail';
-
-}
-
-//编辑信息
-function editDepotHead(index, status){
- if(status == "1" || status == "2") {
- $.messager.alert('编辑提示','已审核和已转的单据不能编辑!','warning');
- return;
- }
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata ='';
- if(Number(index).toString()=='NaN'){
- rowsdata=$.parseJSON(index);
- }else{
- rowsdata=$("#tableData").datagrid("getRows")[index];
- }
- $("#ProjectId").focus().val(rowsdata.projectid);
- var ProjectId=rowsdata.projectid;
- if(ProjectId!='') {
- initSystemData_person(ProjectId);
- initSelectInfo_person();
- }
- var TotalPrice = rowsdata.totalprice; //合计金额
- if(pageType === "skip") { //从订单跳转过来
- buildNumber(); //生成单据编号
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- $("#LinkNumber").val(rowsdata.number); //关联订单号
- $("#AccountId").val(defaultAccountId); //初始化默认的账户Id
- $("#DiscountLastMoney").val(TotalPrice); //优惠后金额
- $("#ChangeAmount").val(TotalPrice).attr("data-changeamount", TotalPrice);
- } else {
- $("#Number").val(rowsdata.number).attr("data-defaultNumber",rowsdata.number);
- $("#OperTime").val(rowsdata.opertimeStr);
- $("#LinkNumber").val(rowsdata.linknumber==undefined?"":rowsdata.linknumber); //关联订单号
- $("#AccountId").val(rowsdata.accountid); //账户Id
- $("#DiscountLastMoney").val(rowsdata.discountlastmoney==undefined?"0.00":rowsdata.discountlastmoney); //优惠后金额
- $("#ChangeAmount").val(rowsdata.changeamount).attr("data-changeamount", rowsdata.changeamount);
- }
- $('#OrganId').combobox('setValue', rowsdata.organid==undefined?'':rowsdata.organid);
- $("#HandsPersonId").val(rowsdata.handspersonid);
- $("#Remark").val(rowsdata.remark);
- $("#Discount").val(rowsdata.discount==undefined?"0":rowsdata.discount);
- $("#DiscountMoney").val(rowsdata.discountmoney==undefined?"0.00":rowsdata.discountmoney);
- $("#Debt").val(Number((rowsdata.discountlastmoney==undefined?'0.00':rowsdata.discountlastmoney-rowsdata.changeamount)).toFixed(2));
- $("#AccountDay").val(rowsdata.accountday==undefined?"":rowsdata.accountday); //结算天数
- preTotalPrice = rowsdata.totalprice; //记录前一次合计金额,用于扣预付款
- $("#AllocationProjectId").val(rowsdata.allocationprojectid);
- oldNumber = rowsdata.number; //记录编辑前的单据编号
- oldId = rowsdata.id; //记录单据Id
- var editTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- depotHeadID = rowsdata.id;
- if(rowsdata.salesman){
- var arr = rowsdata.salesman.split(",");
- var salesmanArray = [];
- for(var i=0;i",""));
- }
- }
- $("#Salesman").combobox('setValues', salesmanArray);
- }
- //采购入库、销售出库的多账户加载
- if(rowsdata.accountidlist!=undefined && rowsdata.accountmoneylist!=undefined){
- $("#AccountId").val("many"); //下拉框选中多账户
- var accountArr = rowsdata.accountidlist.split(",");
- var accountMoneyArr = rowsdata.accountmoneylist.split(",");
- accountMoneyArr = changeListFmtPlus(accountMoneyArr) //将数组单个金额中的数值转为正数
-
- $("#AccountId").attr("data-accountArr", JSON.stringify(accountArr)).attr("data-accountMoneyArr", JSON.stringify(accountMoneyArr)); //json数据存储
- $(".many-account-ico").show(); //显示多账户的ico图标
- }
-
- //采购入库、销售出库的费用数据加载
- if(rowsdata.othermoneylist &&rowsdata.othermoneyitem){
- $("#OtherMoney").val(rowsdata.othermoney==undefined?"0":rowsdata.othermoney); //采购费用、销售费用
- var itemArr = rowsdata.othermoneylist.split(",");
- var itemMoneyArr = rowsdata.othermoneyitem.split(",");
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
-
- initTableData_material("edit",TotalPrice); //商品列表
- reject(); //撤销下、刷新商品列表
- if(pageType === "skip") {
- url = '/depotHead/addDepotHeadAndDetail'; //如果是从订单跳转过来,则此处为新增的接口
- //jshjshjsh
- $("#depotHeadFM .datagrid-body").find("[field='DepotId']").click();
- } else {
- url = '/depotHead/updateDepotHeadAndDetail?id=' + rowsdata.id; //更新接口
- }
-}
-
-//查看信息
-function showDepotHead(index){
- // var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var manyAccountMoney = 0; //多账户合计-零售
- $("#ProjectIdShow").text(rowsdata.projectName);
- $("#NumberShow").text(rowsdata.number);
- $("#OperTimeShow").text(rowsdata.opertimeStr);
- $('#OrganIdShow').text(rowsdata.organName==undefined?'':rowsdata.organName);
- $("#HandsPersonIdShow").text(rowsdata.handsPersonName);
- if(rowsdata.accountName && rowsdata.accountName!=undefined){
- $("#AccountIdShow").text(rowsdata.accountName); //结算账户
- } else {
- var accountArr = (rowsdata.accountidlist==undefined?"":rowsdata.accountidlist).split(","); //账户id列表
- var accountMoneyArr =(rowsdata.accountmoneylist==undefined?"":rowsdata.accountmoneylist).split(","); //账户金额列表
- var accountIdShow = "";
- for(var j =0;j 查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- depotHeadID = rowsdata.id;
- initTableData_material_show(TotalPrice); //商品列表-查看状态
- if(rowsdata.salesman){
- var arr = rowsdata.salesman.split(",");
- var salesmanStr = "";
- for(var i=0;i","");
- }
- else {
- salesmanStr += arr[i].replace("<","").replace(">","") + ",";
- }
- }
- }
- $.ajax({
- type: "get",
- url: "/person/getPersonByIds",
- data: {
- personIDs: salesmanStr
- },
- success:function(res){
- if(res && res.code === 200){
- if(res.data) {
- $("#SalesmanShow").text(res.data.names); //销售人员列表
- }
- }
- },
- error:function(){
-
- }
- });
- }
-}
-
-//绑定操作事件
-function bindEvent(){
- showDepotHeadDetails(1,initPageSize); //初始化时自动查询
- //搜索处理
- $("#searchBtn").off("click").on("click",function(){
- showDepotHeadDetails(1,initPageSize);
- var opts = $("#tableData").datagrid('options');
- var pager = $("#tableData").datagrid('getPager');
- opts.pageNumber = 1;
- opts.pageSize = initPageSize;
- pager.pagination('refresh',
- {
- pageNumber:1,
- pageSize:initPageSize
- });
- });
-
- //重置按钮
- $("#searchResetBtn").unbind().bind({
- click:function(){
- //$("#searchProjectId").val("");
- $("#searchState").val("");
- $("#searchBeginTime").val("");
- $("#searchEndTime").val("");
- //加载完以后重新初始化
- $("#searchBtn").click();
- }
- });
-
- //检查单据编号是否存在
- function checkDepotHeadNumber() {
- var thisNumber = $.trim($("#Number").val());
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(thisNumber.length > 0 &&( oldNumber.length ==0 || thisNumber != oldNumber))
- {
- $.ajax({
- type:"get",
- url: "/depotHead/checkIsNumberExist",
- dataType: "json",
- async : false,
- data: ({
- DepotHeadID : oldId,
- Number : thisNumber
- }),
- success: function (tipInfo)
- {
- flag = tipInfo;
- if(tipInfo)
- {
- $.messager.alert('提示','抱歉,该单据编号已经存在','warning');
- return;
- }
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','检查单据编号是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
- //保存信息
- /**
- * 2019-01-25
- * 我对这个方法的实现结果存在严重怀疑,决定重构
- * 有如下疑点:
- * 1、保存完主表,返回结果后,再发起请求去操作子表,如何保证事务的一致性(业务数据一致性)
- * 2、保存完主表后,再通过selectmax的方式去获取主表主键id完全就是看人品的不可靠的思路
- * 修改计划:
- * 2019-01-25修改零售出库相关操作
- * 修改方式,重写url,将主从表操作合并
- *
- *
- * **/
- $("#saveDepotHead").off("click").on("click",function(){
- if(!$('#depotHeadFM').form('validate')){
- return;
- }
- else {
- //如果初始编号被修改了,就要判断单据编号是否存在
- if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
- //调用查询单据编号是否重名的方法
- if(checkDepotHeadNumber()){
- return;
- }
- }
- //输入框提示
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择购买单位!','warning');
- return;
- }
- if(!$('#AccountId').val()){
- $.messager.alert('提示','请选择收款账户!','warning');
- return;
- }
- if (editIndex != undefined) {
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- }
- //进行明细的校验
- if(depotHeadID ==0) {
- //新增模式下
- if (!CheckData("add")) {
- return;
- }
- }
- else {
- //编辑模式下
- if (!CheckData("edit")) {
- return;
- }
- }
- var OrganId = null, ProjectId = null,AllocationProjectId = null;
- var ChangeAmount = $.trim($("#ChangeAmount").val())-0;
- var TotalPrice = $("#depotHeadFM .datagrid-footer [field='AllPrice'] div").text();
- if($('#OrganId').length){
- OrganId = $('#OrganId').combobox('getValue');
- }
- var accountMoneyList = $("#AccountId").attr("data-accountmoneyarr"); //账户金额列表-多账户
- var accountMoneyArr;
- if(accountMoneyList) {
- accountMoneyList = accountMoneyList.replace("[","").replace("]","").toString();
- var reg=new RegExp("\"","g"); //创建正则RegExp对象
- accountMoneyList = accountMoneyList.replace(reg,""); //替换所有的双引号
- accountMoneyArr = accountMoneyList.split(","); //转为数组
- }
- //零售时候,可以从会员预付款中扣款
- var thisPayType = "现付";
- var SalesmanStr = "";
- var Salesman = $('#Salesman').combobox('getValues').toString(); //销售人员
- if(Salesman) {
- var SalesmanArray = Salesman.split(",");
- for (var i = 0; i < SalesmanArray.length; i++) {
- if (i === SalesmanArray.length - 1) {
- SalesmanStr += "<" + SalesmanArray[i] + ">";
- }
- else {
- SalesmanStr += "<" + SalesmanArray[i] + ">,";
- }
- }
- }
- var getAccountID = $.trim($("#AccountId").val());
- if($("#AccountId").val() === "many"){ //多账户
- getAccountID = null;
- }
- var infoStr=JSON.stringify({
- Type: listType,
- SubType: listSubType,
- ProjectId: ProjectId,
- AllocationProjectId: AllocationProjectId,
- DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
- Number: $.trim($("#Number").val()),
- LinkNumber: $.trim($("#LinkNumber").val()),
- OperTime: $("#OperTime").val(),
- OrganId: OrganId,
- HandsPersonId: $.trim($("#HandsPersonId").val()),
- Salesman: SalesmanStr, //销售人员
- AccountId: getAccountID,
- ChangeAmount: ChangeAmount, //付款/收款
- TotalPrice: TotalPrice, //合计
- PayType: thisPayType, //现付/预付款
- Remark: $.trim($("#Remark").val()),
- AccountIdList: $("#AccountId").attr("data-accountarr"), //账户列表-多账户
- AccountMoneyList: accountMoneyArr ? JSON.stringify(accountMoneyArr) : "", //账户金额列表-多账户
- Discount: $.trim($("#Discount").val()),
- DiscountMoney: $.trim($("#DiscountMoney").val()),
- DiscountLastMoney: $.trim($("#DiscountLastMoney").val()),
- OtherMoney: $.trim($("#OtherMoney").val()), //采购费用、销售费用
- OtherMoneyList: $("#OtherMoney").attr("data-itemarr"), //支出项目列表-涉及费用
- OtherMoneyItem: $("#OtherMoney").attr("data-itemmoneyarr"), //支出项目金额列表-涉及费用
- AccountDay: $("#AccountDay").val() //结算天数
- });
- /**
- * 零售出库,单独操作
- * */
- if(url.indexOf("/depotHead/addDepotHeadAndDetail")>=0){
- addDepotHeadAndDetail(url,infoStr);
- return;
- }else if(url.indexOf("/depotHead/updateDepotHeadAndDetail")>=0){
- updateDepotHeadAndDetail(url,infoStr,preTotalPrice);
- return;
- }
-
- }
- });
-
- //打印单据
- $("#printDepotHeadShow").off("click").on("click",function(){
- var tableString = $("#depotHeadDlgShow").html();
- localStorage.setItem("tableString",tableString);
- window.open("../../js/print/print_form.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
- });
-
- //初始化键盘enter事件
- $(document).keydown(function(event){
- //兼容 IE和firefox 事件
- var e = window.event || event;
- var k = e.keyCode||e.which||e.charCode;
- //兼容 IE,firefox 兼容
- var obj = e.srcElement ? e.srcElement : e.target;
- //绑定键盘事件为 id是指定的输入框才可以触发键盘事件 13键盘事件 ---遗留问题 enter键效验 对话框会关闭问题
- if(k == "13"&&(obj.id=="State"||obj.id=="Number"))
- {
- $("#saveDepotHead").click();
- }
- //搜索按钮添加快捷键
- if(k == "13"&&(obj.id=="searchState"||obj.id=="searchNumber"||obj.id=="searchMaterial"))
- {
- $("#searchBtn").click();
- }
- });
-
- //优惠率输入框事件
- $("#Discount").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountNum = $(this).val();
- var discountMoney = (discountNum/100*totalPrice).toFixed(2);
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#DiscountMoney").val(discountMoney); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //优惠金额输入框事件
- $("#DiscountMoney").off("keyup").on("keyup",function(){
- var footer =$("#depotHeadFM .datagrid-footer");
- var totalPrice = footer.find("[field='TaxLastMoney']").find("div").text();
- var discountMoney = $(this).val();
- var discount = (discountMoney/totalPrice).toFixed(2)*100;
- var discountLastMoney = (totalPrice - discountMoney).toFixed(2);
- $("#Discount").val(discount); //优惠金额
- $("#DiscountLastMoney").val(discountLastMoney); //优惠后金额
- if($("#AccountId").val()!=="many"){
- $("#ChangeAmount").val(discountLastMoney); //本次付、收款
- }
- var changeAmountNum = $("#ChangeAmount").val()-0; //本次付款或者收款
- $("#Debt").val((discountLastMoney-changeAmountNum).toFixed(2)); //本次欠款
- });
-
- //付款、收款输入框事件
- $("#ChangeAmount").off("keyup").on("keyup",function(){
- var discountLastMoney = $("#DiscountLastMoney").val();
- var changeAmount = $(this).val();
- var debtMoney = (discountLastMoney - changeAmount).toFixed(2);
- $("#Debt").val(debtMoney); //本次欠款
- });
-
- //多账户结算窗口弹出事件
- function depotHeadAccountDlgFun(){
- $('#depotHeadAccountDlg').dialog('open').dialog('setTitle','
多账户结算');
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").remove(); //先移除输入栏目
- $("#accountMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#depotHeadAccountDlg .tabs-tmp .account-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#depotHeadAccountDlg .tabs-tmp tbody").html();
- var accountDlgHead = $("#depotHeadAccountDlg .account-head-tmp");
- accountDlgHead.after(contentTmp);
- }
-
- //获取账户信息
- function accountDlgFun() {
- var options = "";
- if(accountList !=null){
- for(var i = 0 ;i < accountList.length;i++) {
- var account = accountList[i];
- options += '';
- }
- $(".account-id-dlg").empty().append("").append(options);
- }
- }
- accountDlgFun(); //获取账户信息
- $("#depotHeadAccountDlg .tabs-tmp").hide(); //隐藏模板
-
- //账户金额输入框事件-多账户
- $("#depotHeadAccountDlg .account-dlg .account-money-dlg").off("keyup").on("keyup",function(){
- var totalAccoutNum = 0;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var eachAccountMoney = $(this).find(".account-money-dlg").val()-0;
- totalAccoutNum += eachAccountMoney;
- });
- $("#accountMoneyTotalDlg").text(totalAccoutNum);
- });
-
- //结算多账户列表的切换事件
- $("#depotHeadAccountDlg .account-dlg .account-id-dlg").off("change").on("change",function(){
- var selectAccount = $(this).children('option:selected').text();
- if(selectAccount === ""){
- var thisMoneyDom = $(this).closest(".account-content-tmp").find(".account-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text() - 0;
- $("#accountMoneyTotalDlg").text(accountMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //账户为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveDepotHeadAccountDlg").off("click").on("click", function(){
- //完成多账户的json数据存储
- var accountArr = []; //账户id数组
- var accountMoneyArr = []; //账户金额数组
- var errorIndex = -1;
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var thisAccId = $(this).find(".account-id-dlg").val();
- var thisAccMoney = $(this).find(".account-money-dlg").val();
- if(!thisAccId && thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && !thisAccMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisAccId && thisAccMoney) {
- accountArr.push(thisAccId);
- accountMoneyArr.push(thisAccMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var discountLastMoneyNum =$("#DiscountLastMoney").val()-0; //优惠后金额
- var accountMoneyTotal = $("#accountMoneyTotalDlg").text()-0; //本次付款或者收款
- if(accountMoneyTotal===0){
- $.messager.alert('错误提示',"请填写金额后保存",'warning');
- return;
- }
- if(accountArr.length && accountMoneyArr.length) {
- $("#AccountId").attr("data-accountArr",JSON.stringify(accountArr)).attr("data-accountMoneyArr",JSON.stringify(accountMoneyArr)); //json数据存储
- }
- $("#ChangeAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
- $("#Debt").val((discountLastMoneyNum-accountMoneyTotal).toFixed(2)); //本次欠款
- $("#depotHeadAccountDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#AccountId").attr("data-accountArr")){
- $("#depotHeadAccountDlg").dialog('close');
- }
- else {
- $("#depotHeadAccountDlg").dialog('close');
- $("#AccountId").val("").removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- }
- //多账户-取消按钮
- $("#cancelDepotHeadAccountDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //多账户-右上角的关闭按钮
- $("#depotHeadAccountDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
- }
- //点击多账户,弹出输入框
- $("#AccountId").off("change").on("change",function(){
- var selectText = $(this).children('option:selected').text();
- if(selectText === "多账户"){
- $("#ChangeAmount").prop("readonly","readonly");
- depotHeadAccountDlgFun();
- $(".many-account-ico").show(); //显示多账户小图标
- }
- else{
- $(this).removeAttr("data-accountArr").removeAttr("data-accountMoneyArr"); //将下拉置空并把缓存参数清空
- $("#ChangeAmount").removeProp("readonly","readonly");
- $(".many-account-ico").hide(); //隐藏多账户小图标
- }
- });
-
- //结算账户-多账户小图标-点击事件
- $(".many-account-ico").off("click").on("click",function(){
- depotHeadAccountDlgFun();
- //给弹窗赋值-多账户数据
- var accountArr = $("#AccountId").attr("data-accountArr");
- accountArr = JSON.parse(accountArr);
- var accountMoneyArr = $("#AccountId").attr("data-accountMoneyArr");
- accountMoneyArr = JSON.parse(accountMoneyArr);
- $("#depotHeadAccountDlg .account-dlg .account-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".account-id-dlg").val(accountArr[index]);
- $(this).find(".account-money-dlg").val(accountMoneyArr[index]);
- });
- $("#accountMoneyTotalDlg").text($("#ChangeAmount").val());
- });
-
- //点击采购费用、销售费用的事件
- $(".other-money-ico").off("click").on("click",function(){
- $('#otherMoneyDlg').dialog('open').dialog('setTitle','
'+ listSubType +'费用');
- $("#otherMoneyDlg .money-dlg .money-content-tmp").remove(); //先移除输入栏目
- $("#otherMoneyTotalDlg").text(0); //将合计初始化为0
- for(var i=0; i<6; i++) {
- $("#otherMoneyDlg .tabs-tmp .money-content-tmp").attr("data-index",5-i); //添加索引
- var contentTmp = $("#otherMoneyDlg .tabs-tmp tbody").html();
- var moneyDlgHead = $("#otherMoneyDlg .money-head-tmp");
- moneyDlgHead.after(contentTmp);
- }
-
- //获取支出项目信息
- function moneyDlgFun() {
- var options = "";
- if(outItemList !=null){
- for(var i = 0 ;i < outItemList.length;i++) {
- var money = outItemList[i];
- options += '';
- }
- $(".money-id-dlg").empty().append("").append(options);
- }
- }
- moneyDlgFun(); //获取支出项目信息
- $("#otherMoneyDlg .tabs-tmp").hide(); //隐藏模板
-
- //支出项目的金额输入框事件
- $("#otherMoneyDlg .money-dlg .other-money-dlg").off("keyup").on("keyup",function(){
- var totalMoneyNum = 0;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var eachOtherMoney = $(this).find(".other-money-dlg").val()-0;
- totalMoneyNum += eachOtherMoney;
- });
- $("#otherMoneyTotalDlg").text(totalMoneyNum);
- });
-
- //支出项目列表的切换事件
- $("#otherMoneyDlg .money-dlg .money-id-dlg").off("change").on("change",function(){
- var selectItem = $(this).children('option:selected').text();
- if(selectItem === ""){
- var thisMoneyDom = $(this).closest(".money-content-tmp").find(".other-money-dlg");
- var thisMoney = thisMoneyDom.val()-0;
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text() - 0;
- $("#otherMoneyTotalDlg").text(otherMoneyTotal - thisMoney);
- thisMoneyDom.val(""); //支出项目为空时候,将金额也置为空
- }
- });
-
- //保存按钮事件
- $("#saveOtherMoneyDlg").off("click").on("click", function(){
- //完成支出项目的json数据存储
- var itemArr = []; //支出项目id数组
- var itemMoneyArr = []; //支出项目金额数组
- var errorIndex = -1;
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var thisId = $(this).find(".money-id-dlg").val();
- var thisMoney = $(this).find(".other-money-dlg").val();
- if(!thisId && thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && !thisMoney) {
- errorIndex = $(this).attr("data-index")-0;
- return;
- }
- if(thisId && thisMoney) {
- itemArr.push(thisId);
- itemMoneyArr.push(thisMoney);
- }
- });
- if(errorIndex >-1){
- $.messager.alert('错误提示',"第" + (errorIndex+1) + "行数据存在问题,请修改",'warning');
- return;
- }
- var otherMoneyTotal = $("#otherMoneyTotalDlg").text()-0; //合计金额
- if(otherMoneyTotal === 0){ //0的时候清空缓存数据
- $("#OtherMoney").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr");
- }
- if(itemArr.length && itemMoneyArr.length) {
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
- $("#OtherMoney").val(otherMoneyTotal); //给采购费用、销售费用赋值
- $("#otherMoneyDlg").dialog('close');
- });
-
- //取消事件
- function cancelFun(){
- if($("#OtherMoney").attr("data-itemArr")){
- $("#otherMoneyDlg").dialog('close');
- }
- else {
- $("#otherMoneyDlg").dialog('close');
- $("#OtherMoney").val("").removeAttr("data-itemArr").removeAttr("data-itemMoneyArr"); //将下拉置空并把缓存参数清空
- }
- }
- //费用-取消按钮
- $("#cancelOtherMoneyDlg").off("click").on("click", function(){
- cancelFun();
- });
-
- //费用-右上角的关闭按钮
- $("#otherMoneyDlg").prev().find(".panel-tool-close").off("click").on("click", function(){
- cancelFun();
- });
-
- //给弹窗赋值-采购费用、销售费用数据
- var itemArr = $("#OtherMoney").attr("data-itemArr");
- itemArr = JSON.parse(itemArr);
- var itemMoneyArr = $("#OtherMoney").attr("data-itemMoneyArr");
- itemMoneyArr = JSON.parse(itemMoneyArr);
- $("#otherMoneyDlg .money-dlg .money-content-tmp").each(function(){
- var index = $(this).attr("data-index");
- $(this).find(".money-id-dlg").val(itemArr[index]);
- if(itemMoneyArr[index]!="undefined"){
- $(this).find(".other-money-dlg").val(itemMoneyArr[index]);
- }
- });
- $("#otherMoneyTotalDlg").text($("#OtherMoney").val());
- });
-
- var supplierType = "客户";
- //检查单位名称是否存在 ++ 重名无法提示问题需要跟进
- function checkSupplierName() {
- var supplierName = $.trim($("#supplier").val());
- var orgSupplier = "";
- //表示是否存在 true == 存在 false = 不存在
- var flag = false;
- //开始ajax名称检验,不能重名
- if(supplierName.length > 0 &&( orgSupplier.length ==0 || supplierName != orgSupplier))
- {
- $.ajax({
- type:"get",
- url: "/supplier/checkIsNameExist",
- dataType: "json",
- async : false,
- data: ({
- id : 0,
- name : supplierName
- }),
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data && res.data.status) {
- flag = res.data.status;
- if (flag) {
- $.messager.alert('提示', '单位名称已经存在', 'info');
- return;
- }
- }
- }
- },
- //此处添加错误处理
- error:function() {
- $.messager.alert('提示','检查单位名称是否存在异常,请稍后再试!','error');
- return;
- }
- });
- }
- return flag;
- }
-
- //保存供应商信息
- $("#saveSupplier").off("click").on("click",function() {
- if(validateForm("supplierFM")) {
- return;
- }
- if(checkSupplierName()){
- return;
- }
- var reg = /^([0-9])+$/;
- var phonenum = $.trim($("#phonenum").val());
- if(phonenum.length>0 && !reg.test(phonenum))
- {
- $.messager.alert('提示','电话号码只能是数字','info');
- $("#phonenum").val("").focus();
- return;
- }
- var beginNeedGet = $.trim($("#BeginNeedGet").val());
- var beginNeedPay = $.trim($("#BeginNeedPay").val());
- if(beginNeedGet && beginNeedPay) {
- $.messager.alert('提示','期初应收和期初应付不能同时输入','info');
- return;
- }
- var url = '/supplier/add';
- var supObj = $("#supplierFM").serializeObject();
- supObj.type = supplierType;
- supObj.enabled = 1;
- $.ajax({
- url: url,
- type:"post",
- dataType: "json",
- data:{
- info: JSON.stringify(supObj)
- },
- success: function(res) {
- if (res) {
- $('#supplierDlg').dialog('close');
- initSupplier(); //刷新供应商
- }
- }
- });
- });
-}
-
-function showDepotHeadDetails(pageNo,pageSize){
- var materialParam = $.trim($("#searchMaterial").val());
- var beginTime = $.trim($("#searchBeginTime").val());
- var endTime = $.trim($("#searchEndTime").val());
- if(beginTime) {
- beginTime = beginTime + ' 00:00:00';
- }
- if(endTime) {
- endTime = endTime + ' 23:59:59';
- }
- $.ajax({
- type: "get",
- url: "/depotHead/list",
- dataType: "json",
- data: ({
- search: JSON.stringify({
- type: listType,
- subType: listSubType,
- state: $.trim($("#searchState").val()),
- number: $.trim($("#searchNumber").val()),
- beginTime: beginTime,
- endTime: endTime,
- materialParam: materialParam,
- depotIds: depotString
- }),
- currentPage: pageNo,
- pageSize: pageSize
- }),
- success: function (res) {
- if(res && res.code === 200){
- if(res.data && res.data.page) {
- $("#tableData").datagrid('loadData', res.data.page);
- }
- }
- },
- //此处添加错误处理
- error: function () {
- $.messager.alert('查询提示', '查询数据后台异常,请稍后再试!', 'error');
- return;
- }
- });
-}
-
-//自动计算事件
-function autoReckon() {
- //延时绑定事件
- setTimeout(function(){
- var body =$("#depotHeadFM .datagrid-body");
- var footer =$("#depotHeadFM .datagrid-footer");
- var input = ".datagrid-editable-input";
- //点击商品下拉框,自动加载数量、单价、金额
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //点击库存文本框,字段计算库存
- body.find("[field='Stock']").find(input).off("click").on("click",function(){
- var depotId = body.find("[field='DepotId']").find(".combo-value").val();
- var mId = body.find("[field='MaterialId']").find(".combo-value").val();
- var monthTime = getNowFormatMonth();
- if(depotId && mId){
- var ratio = body.find("[field='Unit']").find(input).attr("data-ratio");
- body.find("[field='Stock']").find(input).prop("readonly","readonly");
- //在新增的时候,这个ratio有值;在编辑的时候,这个ratio为undefined
- var type = "click"; //type 类型:点击 click,选择 select
- findStockNumById(depotId, mId, monthTime, body, input, ratio, type);
- }
- else{
- body.find("[field='Stock']").find(input).val(0).attr("data-stock",0); //加载库存数据
- }
- });
- //修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计
- body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber =$(this).val()-0; //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
-
- });
- //修改单价,自动计算金额和合计
- body.find("[field='UnitPrice']").find(input).off("keyup").on("keyup",function(){
- var UnitPrice =$(this).val()-0; //单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //点击单价,自动提示参考价格列表
- body.find("[field='UnitPrice']").find(input).off("click").on("click",function(){
- var self = this;
- var mValue = body.find("[field='MaterialId'] .combo-value").attr("value"); //获取选中的商品id
- if(!mValue) {
- return;
- }
- else {
- $.ajax({
- url: "/material/findById",
- type: "get",
- dataType: "json",
- data: {
- id: mValue - 0
- },
- success: function(res){
- if(res && res.rows && res.rows[0]) {
- var retailPrice = res.rows[0].RetailPrice;
- var presetPriceOne = res.rows[0].PresetPriceOne;
- var presetPriceTwo = res.rows[0].PresetPriceTwo;
- //定义模版
- var temp = "";
- temp +="
";
- temp +="- 批发价:" + presetPriceTwo + "
";
- temp +="- 零售价:" + retailPrice + "
";
- temp +="
";
- temp +="
";
- if($('.price-list').length){
- $('.price-list').remove(); //如果存在价格列表先移除
- }
- else {
- if(presetPriceTwo != undefined){ //多单位的商品
- $(self).after(temp); //加载列表信息
- }
- }
- $('.price-list ul li').off("click").on("click",function(){
- var price = $(this).text();
- price = price.substring(price.indexOf(":") + 1);
- $(self).val(price);
- $(self).keyup(); //模拟键盘操作
- $('.price-list').remove(); //移除价格列表
- });
- //点击空白处移除价格列表
- $(".datagrid-body").off("click").on("click",function(){
- $('.price-list').remove(); //移除价格列表
- });
- }
- },
- error: function(){
- $.messager.alert('错误提示','查询商品信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
- //修改含税单价,自动计算单价、金额、税额、价税合计和合计
- body.find("[field='TaxUnitPrice']").find(input).off("keyup").on("keyup",function(){
- var TaxUnitPrice =$(this).val()-0; //含税单价
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var UnitPrice = TaxUnitPrice/(1+taxRate/100); //计算单价
- body.find("[field='UnitPrice']").find(input).val((UnitPrice).toFixed(2)); //单价
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- body.find("[field='AllPrice']").find(input).val((UnitPrice*OperNumber).toFixed(2)); //金额
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改金额,自动计算单价、税额、价税合计和合计
- body.find("[field='AllPrice']").find(input).off("keyup").on("keyup",function(){
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var taxRate = body.find("[field='TaxRate']").find(input).val(); //税率
- var AllPrice =$(this).val()-0; //金额
- var UnitPrice = (AllPrice/OperNumber).toFixed(2);
- body.find("[field='UnitPrice']").find(input).val(UnitPrice); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税率,自动计算含税单价、税额、价税合计和合计
- body.find("[field='TaxRate']").find(input).off("keyup").on("keyup",function(){
- var taxRate =$(this).val()-0; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改税额,自动计算税率、含税单价、价税合计和合计
- body.find("[field='TaxMoney']").find(input).off("keyup").on("keyup",function(){
- var taxMoney =$(this).val()-0; //税额
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = taxMoney/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxLastMoney']").find(input).val((UnitPrice*OperNumber*(1+taxRate/100)).toFixed(2)); //价税合计
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
- //修改价税合计,自动计算税率、含税单价、税额和合计
- body.find("[field='TaxLastMoney']").find(input).off("keyup").on("keyup",function(){
- var taxLastMoney =$(this).val()-0; //价税合计
- var AllPrice = body.find("[field='AllPrice']").find(input).val(); //金额
- var taxRate = (taxLastMoney-AllPrice)/AllPrice*100; //税率
- var OperNumber = body.find("[field='OperNumber']").find(input).val(); //数量
- var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
- body.find("[field='TaxUnitPrice']").find(input).val((UnitPrice*(1+taxRate/100)).toFixed(2)); //含税单价
- body.find("[field='TaxRate']").find(input).val((taxRate).toFixed(2)); //税率
- body.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
- statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
- });
-
- //加载税率
- if(thisTaxRate) {
- body.find("[field='TaxRate']").find(input).val(thisTaxRate);
- }
- else {
- body.find("[field='TaxRate']").find(input).val(0); //默认为0
- }
-
- //在商品类型加载 组装件、普通子件
- var mType = body.find("[field='MType']");
- var rowListLength = mType.find(input).closest(".datagrid-row").attr("datagrid-row-index");
- var mTypeValue = "组合件";
- if(rowListLength > 0){
- mTypeValue = "普通子件";
- }
- },500);
-}
-
-//结束编辑
-function endEditing() {
- if (editIndex == undefined) { return true }
- if ($('#materialData').datagrid('validateRow', editIndex)) {
- //仓库信息
- var edDepot = $('#materialData').datagrid('getEditor', {index:editIndex,field:'DepotId'});
- var DepotName = $(edDepot.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName;
- //商品信息
- var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialId'});
- var MaterialName = $(edMaterial.target).combobox('getText');
- $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName;
- $('#materialData').datagrid('endEdit', editIndex);
- editIndex = undefined;
- return true;
- } else {
- return false;
- }
-}
-//单击
-function onClickRow(index) {
- if (editIndex != index) {
- if (endEditing()) {
- $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index);
- editIndex = index;
- autoReckon();
- } else {
- $('#materialData').datagrid('selectRow', editIndex);
- }
- }
-}
-//新增
-function append(){
- if (endEditing()) {
- $('#materialData').datagrid('appendRow', {DepotId:defDepotId});
- editIndex = $('#materialData').datagrid('getRows').length - 1;
- $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
-}
-//删除
-function batchDel(){
- /**
- * 重写一下删除的逻辑
- * 获取所有选中行,直接从列表中移除
- * 点击保存时,将需要后台删除的数据提交到服务器
- * **/
- /**
- * create by: qiankunpingtai
- * create time: 2019/3/20 16:26
- * description:
- * 这个地方比较坑的,花了一个多小时才搞明白为什么
- * 1、删除之前必须先调用endEditing结束编辑
- * 2、如果只是调用endEditing结束编辑那么正在编辑行的被选中状态会被去掉
- * 所以要在调用endEditing先获取选中的行
- */
- //如果编辑的行一开始是选中状态,结束编辑后仍然是选中状态
- var row = $('#materialData').datagrid('getChecked');
- if (endEditing()) {
- if (row.length == 0) {
- $.messager.alert('删除提示', '没有记录被选中!', 'info');
- return;
- }
- if (row.length > 0) {
- $.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条单据信息吗?', function (r) {
- if (r) {
- for (var i = 0; i < row.length; i++) {
- $('#materialData').datagrid('deleteRow', $('#materialData').datagrid("getRowIndex", row[i]));
- }
- }
- });
- }
- }
-}
-function removeit(){
- if (editIndex == undefined) { return }
- $('#materialData').datagrid('cancelEdit', editIndex)
- .datagrid('deleteRow', editIndex);
- editIndex = undefined;
-}
-//撤销
-function reject() {
- $('#materialData').datagrid('rejectChanges');
- editIndex = undefined;
-}
-//判断
-function CheckData(type) {
- var change = $('#materialData').datagrid('getChanges').length;
- if(type =="add" && !change) {
- $.messager.alert('提示','请输入明细信息!','warning');
- return false;
- }
- var row = $('#materialData').datagrid('getRows');
- if(!row.length){
- $.messager.alert('提示',"请输入明细信息!",'info');
- return false;
- }
- var totalRowNum = "";
- for (var i = 0; i < row.length; i++) {
- if (row[i].DepotId == "" || row[i].MaterialId == "" || row[i].OperNumber == "" || row[i].UnitPrice === "" || row[i].AllPrice === "") {
- totalRowNum += (i + 1) + "、";
- }
- }
- if (totalRowNum != "") {
- var totalRowNum = totalRowNum.substring(0, totalRowNum.length - 1);
- $.messager.alert('提示',"第" + totalRowNum + "行数据填写不完整!",'info');
- return false;
- }
- return true;
-}
-
-
-/**
- * 新增单据主表及单据子表
- * */
-function addDepotHeadAndDetail(url,infoStr){
- var inserted = null;
- if(pageType === "skip") {
- inserted = $("#materialData").datagrid('getChanges', "updated");
- } else {
- inserted = $("#materialData").datagrid('getChanges', "inserted");
- }
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated)
- }),
- success: function (tipInfo){
-
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
-
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
-
-
- });
-}
-/**
- * 修改单据主表及单据子表
- * */
-function updateDepotHeadAndDetail(url,infoStr,preTotalPrice){
- var inserted = $("#materialData").datagrid('getChanges', "inserted");
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- id:url.substring(url.lastIndexOf("?id=")+4,url.length),
- info:infoStr,
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- preTotalPrice:preTotalPrice
- }),
- success: function (tipInfo){
- if(tipInfo){
- if(tipInfo.code!=200){
- $.messager.alert('提示', tipInfo.msg, 'error');
- return;
- }
- $.messager.alert('提示','保存成功!','info');
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
- if (endEditing()) {
- $('#materialData').datagrid('acceptChanges');
- }
- }else {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
-
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
-}
-
-
-
-
diff --git a/erp_web/pages/financial/advance_in.html b/erp_web/pages/financial/advance_in.html
index d5d113f6..05e97781 100644
--- a/erp_web/pages/financial/advance_in.html
+++ b/erp_web/pages/financial/advance_in.html
@@ -14,7 +14,7 @@
-
+
diff --git a/erp_web/pages/financial/giro.html b/erp_web/pages/financial/giro.html
index f9b80d47..8a134d84 100644
--- a/erp_web/pages/financial/giro.html
+++ b/erp_web/pages/financial/giro.html
@@ -14,7 +14,7 @@
-
+
diff --git a/erp_web/pages/financial/item_in.html b/erp_web/pages/financial/item_in.html
index 8cb1e1b9..bf9f4522 100644
--- a/erp_web/pages/financial/item_in.html
+++ b/erp_web/pages/financial/item_in.html
@@ -14,7 +14,7 @@
-
+
diff --git a/erp_web/pages/financial/item_out.html b/erp_web/pages/financial/item_out.html
index 202d1f97..ae433360 100644
--- a/erp_web/pages/financial/item_out.html
+++ b/erp_web/pages/financial/item_out.html
@@ -14,7 +14,7 @@
-
+
diff --git a/erp_web/pages/financial/money_in.html b/erp_web/pages/financial/money_in.html
index 1219039e..1a484101 100644
--- a/erp_web/pages/financial/money_in.html
+++ b/erp_web/pages/financial/money_in.html
@@ -14,7 +14,7 @@
-
+
diff --git a/erp_web/pages/financial/money_out.html b/erp_web/pages/financial/money_out.html
index 06fe3c1d..d5760891 100644
--- a/erp_web/pages/financial/money_out.html
+++ b/erp_web/pages/financial/money_out.html
@@ -14,7 +14,7 @@
-
+
diff --git a/erp_web/pages/manage/account.html b/erp_web/pages/manage/account.html
index bab51dea..6a1166c5 100644
--- a/erp_web/pages/manage/account.html
+++ b/erp_web/pages/manage/account.html
@@ -129,18 +129,12 @@
},
{title: '备注', field: 'remark', width: 100},
{
- title: '操作', field: 'op', align: "center", width: 210, formatter: function (value, rec,index) {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/5 10:30
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js实现
- */
+ title: '操作', field: 'op', align: "center", width: 210, formatter: function (value, rec) {
var str = '';
- str += '
流水 ';
- str += '
编辑 ';
- str += '
删除 ';
+ var rowInfo = rec.id + 'AaBb' + rec.name + 'AaBb' + rec.serialno + 'AaBb' + rec.initialamount + 'AaBb' + rec.currentamount + 'AaBb' + rec.remark;
+ str += '
流水 ';
+ str += '
编辑 ';
+ str += '
删除 ';
return str;
}
}
@@ -221,16 +215,16 @@
}
//删除结算账户
- function deleteAccount(id) {
+ function deleteAccount(accountInfo) {
$.messager.confirm('删除确认', '确定要删除此结算账户吗?', function (r) {
if (r) {
- // var accountTotalInfo = accountInfo.split("AaBb");
+ var accountTotalInfo = accountInfo.split("AaBb");
$.ajax({
type: "post",
url: "/account/batchDeleteAccountByIds",
dataType: "json",
data: ({
- ids: id
+ ids: accountTotalInfo[0]
}),
success: function (res) {
if(res && res.code == 200) {
@@ -238,7 +232,7 @@
} else {
if(res && res.code == 601){
var jsondata={};
- jsondata.ids=id;
+ jsondata.ids=accountTotalInfo[0];
jsondata.deleteType='2';
var type='single';
batDeleteAccountForceConfirm(res,"/account/batchDeleteAccountByIds",jsondata,type);
@@ -443,22 +437,23 @@
});
//编辑结算账户
- function editAccount(index) {
- var rowsdata = $("#tableData").datagrid("getRows")[index];
+ function editAccount(accountTotalInfo) {
+ var accountInfo = accountTotalInfo.split("AaBb");
var row = {
- name: rowsdata.name,
- serialNo: rowsdata.serialNo,
- initialAmount: rowsdata.initialamount,
- currentAmount: rowsdata.currentamount,
- remark: rowsdata.remark
+ name: accountInfo[1],
+ serialNo: accountInfo[2],
+ initialAmount: accountInfo[3],
+ currentAmount: accountInfo[4],
+ remark: accountInfo[5]
};
- oldAccount = rowsdata.name;
+ oldAccount = accountInfo[1];
$('#accountDlg').dialog('open').dialog('setTitle', '
编辑结算账户');
$(".window-mask").css({width: webW, height: webH});
$('#accountFM').form('load', row);
+ accountID = accountInfo[0];
//焦点在名称输入框==定焦在输入文字后面
- $("#account").val("").focus().val(rowsdata.name);
- url = '/account/update?id=' + rowsdata.id;
+ $("#account").val("").focus().val(accountInfo[1]);
+ url = '/account/update?id=' + accountInfo[0];
}
//检查结算账户 名称是否存在 ++ 重名无法提示问题需要跟进
@@ -545,11 +540,10 @@
});
}
- function showAccountInOutList(index) {
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- var accountId = rowsdata.id;
- var initialAmount = rowsdata.serialno;
+ function showAccountInOutList(accountInfo) {
+ var info = accountInfo.split("AaBb");
+ var accountId = info[0];
+ var initialAmount = info[3];
$('#accountDetailListDlg').dialog('open').dialog('setTitle', '
查看账户流水');
$(".window-mask").css({width: webW, height: webH});
initAccountDetailData(accountId);
diff --git a/erp_web/pages/manage/app.html b/erp_web/pages/manage/app.html
deleted file mode 100644
index e69de29b..00000000
diff --git a/erp_web/pages/manage/customer.html b/erp_web/pages/manage/customer.html
index 90f328c7..870332c1 100644
--- a/erp_web/pages/manage/customer.html
+++ b/erp_web/pages/manage/customer.html
@@ -13,7 +13,7 @@
-
+
diff --git a/erp_web/pages/manage/depot.html b/erp_web/pages/manage/depot.html
index 4d07bc4c..225072e2 100644
--- a/erp_web/pages/manage/depot.html
+++ b/erp_web/pages/manage/depot.html
@@ -483,26 +483,25 @@
});
//编辑信息
- function editDepot(index) {
- // var depotInfo = depotTotalInfo.split("AaBb");
- var rowsdata = $("#tableData").datagrid("getRows")[index];
+ function editDepot(depotTotalInfo) {
+ var depotInfo = depotTotalInfo.split("AaBb");
- $("#name").focus().val(rowsdata.name);
- $("#sort").val(rowsdata.sort);
- $("#remark").val(rowsdata.remark);
- $("#address").val(rowsdata.address);
- $("#warehousing").val(rowsdata.warehousing);
- $("#truckage").val(rowsdata.truckage);
- $("#principalName").val(transferUndefined(rowsdata.principalName));
- $("#principal").val(transferUndefined(rowsdata.principal));
+ $("#name").focus().val(depotInfo[1]);
+ $("#sort").val(depotInfo[2]);
+ $("#remark").val(depotInfo[3]);
+ $("#address").val(depotInfo[4]);
+ $("#warehousing").val(depotInfo[5].replace("undefined",""));
+ $("#truckage").val(depotInfo[6].replace("undefined",""));
+ $("#principalName").val(depotInfo[7]);
+ $("#principal").val(depotInfo[8]);
$("#selectType").val("principal");
- oldDepot = rowsdata.name;
+ oldDepot = depotInfo[1];
$('#depotDlg').dialog('open').dialog('setTitle', '
编辑仓库信息');
$(".window-mask").css({width: webW, height: webH});
- depotID = rowsdata.id;
+ depotID = depotInfo[0];
//焦点在名称输入框==定焦在输入文字后面
- $("#name").val("").focus().val(rowsdata.name);
- url = '/depot/update?id=' + rowsdata.id;
+ $("#name").val("").focus().val(depotInfo[1]);
+ url = '/depot/update?id=' + depotInfo[0];
}
//检查名称是否存在 ++ 重名无法提示问题需要跟进
diff --git a/erp_web/pages/manage/functions.html b/erp_web/pages/manage/functions.html
index 4cef9212..23a5b007 100644
--- a/erp_web/pages/manage/functions.html
+++ b/erp_web/pages/manage/functions.html
@@ -167,11 +167,11 @@
},
{title: '类型', field: 'type', width: 50},
{
- title: '操作', field: 'op', align: "center", width: 130, formatter: function (value, rec,index) {
+ title: '操作', field: 'op', align: "center", width: 130, formatter: function (value, rec) {
var str = '';
- // var rowInfo = rec.id + 'AaBb' + rec.number + 'AaBb' + rec.name + 'AaBb' + rec.pnumber + 'AaBb' + rec.url
- // + 'AaBb' + rec.state + 'AaBb' + rec.sort + 'AaBb' + rec.enabled + 'AaBb' + rec.type + 'AaBb' + rec.pushbtn;
- str += '
编辑 ';
+ var rowInfo = rec.id + 'AaBb' + rec.number + 'AaBb' + rec.name + 'AaBb' + rec.pnumber + 'AaBb' + rec.url
+ + 'AaBb' + rec.state + 'AaBb' + rec.sort + 'AaBb' + rec.enabled + 'AaBb' + rec.type + 'AaBb' + rec.pushbtn;
+ str += '
编辑 ';
str += '
删除 ';
return str;
}
@@ -381,20 +381,19 @@
});
//编辑信息
- function editFunctions(index) {
- // var functionsInfo = functionsTotalInfo.split("AaBb");
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#Number").focus().val(rowsdata.number);
- $("#Name").focus().val(rowsdata.name);
- $("#PNumber").focus().val(rowsdata.pnumber);
- $("#URL").focus().val(rowsdata.url);
- $("#State").attr("checked", rowsdata.state === true ? true : false);
- $("#Sort").focus().val(rowsdata.sort);
- $("#Enabled").attr("checked", rowsdata.enabled === true ? true : false);
- $("#Type").focus().val(rowsdata.type);
- var pushbtn=rowsdata.pushbtn;
- if (pushbtn) {
- var arr = pushbtn.split(",");
+ function editFunctions(functionsTotalInfo) {
+ var functionsInfo = functionsTotalInfo.split("AaBb");
+
+ $("#Number").focus().val(functionsInfo[1]);
+ $("#Name").focus().val(functionsInfo[2]);
+ $("#PNumber").focus().val(functionsInfo[3]);
+ $("#URL").focus().val(functionsInfo[4]);
+ $("#State").attr("checked", functionsInfo[5] == 'true' ? true : false);
+ $("#Sort").focus().val(functionsInfo[6]);
+ $("#Enabled").attr("checked", functionsInfo[7] == 'true' ? true : false);
+ $("#Type").focus().val(functionsInfo[8]);
+ if (functionsInfo[9] !== "undefined" && functionsInfo[9] !== "") {
+ var arr = functionsInfo[9].split(",");
var pushBtnArray = [];
for (var i = 0; i < arr.length; i++) {
if (arr[i]) {
@@ -409,13 +408,13 @@
$("#PushBtn").combobox('setValues', '');
}
- oldFunctions = rowsdata.name;
+ oldFunctions = functionsInfo[2];
$('#functionsDlg').dialog('open').dialog('setTitle', '
编辑功能信息');
$(".window-mask").css({width: webW, height: webH});
- functionsID = rowsdata.id;
+ functionsID = functionsInfo[0];
//焦点在名称输入框==定焦在输入文字后面
- $("#Name").val("").focus().val(rowsdata.name);
- url = '/functions/update?id=' + rowsdata.id;
+ $("#Name").val("").focus().val(functionsInfo[2]);
+ url = '/functions/update?id=' + functionsInfo[0];
}
//检查名称是否存在 ++ 重名无法提示问题需要跟进
diff --git a/erp_web/pages/manage/inOutItem.html b/erp_web/pages/manage/inOutItem.html
index 30952288..87c1e9ba 100644
--- a/erp_web/pages/manage/inOutItem.html
+++ b/erp_web/pages/manage/inOutItem.html
@@ -136,18 +136,11 @@
{title: '类型', field: 'type', width: 100, align: "center"},
{title: '描述', field: 'remark', width: 200},
{
- title: '操作', field: 'op', align: "center", width: 130, formatter: function (value, rec,index) {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/5 10:30
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js实现
- */
+ title: '操作', field: 'op', align: "center", width: 130, formatter: function (value, rec) {
var str = '';
- // var rowInfo = rec.id + 'AaBb' + rec.name + 'AaBb' + rec.type + 'AaBb' + rec.remark;
- str += '
编辑 ';
- str += '
删除 ';
+ var rowInfo = rec.id + 'AaBb' + rec.name + 'AaBb' + rec.type + 'AaBb' + rec.remark;
+ str += '
编辑 ';
+ str += '
删除 ';
return str;
}
}
@@ -221,16 +214,16 @@
}
//删除收支项目
- function deleteInOutItem(id) {
+ function deleteInOutItem(inOutItemInfo) {
$.messager.confirm('删除确认', '确定要删除此收支项目吗?', function (r) {
if (r) {
- // var inOutItemTotalInfo = inOutItemInfo.split("AaBb");
+ var inOutItemTotalInfo = inOutItemInfo.split("AaBb");
$.ajax({
type: "post",
url: "/inOutItem/batchDeleteInOutItemByIds",
dataType: "json",
data: ({
- ids: id
+ ids: inOutItemTotalInfo[0]
}),
success: function (res) {
if(res && res.code == 200) {
@@ -238,7 +231,7 @@
} else {
if(res && res.code == 601){
var jsondata={};
- jsondata.ids=id;
+ jsondata.ids=inOutItemTotalInfo[0];
jsondata.deleteType='2';
var type='single';
batDeleteInOutItemForceConfirm(res,"/inOutItem/batchDeleteInOutItemByIds",jsondata,type);
@@ -400,23 +393,21 @@
});
//编辑收支项目
- function editInOutItem(index) {
- // var inOutItemInfo = inOutItemTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
+ function editInOutItem(inOutItemTotalInfo) {
+ var inOutItemInfo = inOutItemTotalInfo.split("AaBb");
var row = {
- name: rowsdata.name,
- type: rowsdata.type,
- remark: rowsdata.remark
+ name: inOutItemInfo[1],
+ type: inOutItemInfo[2],
+ remark: inOutItemInfo[3]
};
- oldInOutItem = rowsdata.name;
+ oldInOutItem = inOutItemInfo[1];
$('#inOutItemDlg').dialog('open').dialog('setTitle', '
编辑收支项目');
$(".window-mask").css({width: webW, height: webH});
$('#inOutItemFM').form('load', row);
- inOutItemID = rowsdata.id;
+ inOutItemID = inOutItemInfo[0];
//焦点在名称输入框==定焦在输入文字后面
- $("#inOutItem").val("").focus().val(rowsdata.name);
- url = '/inOutItem/update?id=' + rowsdata.id;
+ $("#inOutItem").val("").focus().val(inOutItemInfo[1]);
+ url = '/inOutItem/update?id=' + inOutItemInfo[0];
}
//检查收支项目 名称是否存在 ++ 重名无法提示问题需要跟进
diff --git a/erp_web/pages/manage/member.html b/erp_web/pages/manage/member.html
index 14db1aab..c3d857d2 100644
--- a/erp_web/pages/manage/member.html
+++ b/erp_web/pages/manage/member.html
@@ -13,7 +13,7 @@
-
+
diff --git a/erp_web/pages/manage/role.html b/erp_web/pages/manage/role.html
index 05009d27..3eb5629f 100644
--- a/erp_web/pages/manage/role.html
+++ b/erp_web/pages/manage/role.html
@@ -117,17 +117,10 @@
{field: 'id', width: 35, align: "center", checkbox: true},
{title: '角色名称', field: 'name', width: 200},
{
- title: '操作', field: 'op', align: "center", width: 130, formatter: function (value, rec,index) {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/5 10:30
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js实现
- */
+ title: '操作', field: 'op', align: "center", width: 130, formatter: function (value, rec) {
var str = '';
- // var rowInfo = rec.id + 'AaBb' + rec.name;
- str += '
编辑 ';
+ var rowInfo = rec.id + 'AaBb' + rec.name;
+ str += '
编辑 ';
str += '
删除 ';
return str;
}
@@ -320,18 +313,18 @@
});
//编辑信息
- function editRole(index) {
- // var roleInfo = roleTotalInfo.split("AaBb");
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#name").focus().val(rowsdata.name);
+ function editRole(roleTotalInfo) {
+ var roleInfo = roleTotalInfo.split("AaBb");
- oldName = rowsdata.name;
+ $("#name").focus().val(roleInfo[1]);
+
+ oldName = roleInfo[1];
$('#roleDlg').dialog('open').dialog('setTitle', '
编辑角色信息');
$(".window-mask").css({width: webW, height: webH});
- roleID = rowsdata.id;
+ roleID = roleInfo[0];
//焦点在名称输入框==定焦在输入文字后面
- $("#name").val("").focus().val(rowsdata.name);
- url = '/role/update?id=' + rowsdata.id;
+ $("#name").val("").focus().val(roleInfo[1]);
+ url = '/role/update?id=' + roleInfo[0];
}
//检查名称是否存在 ++ 重名无法提示问题需要跟进
@@ -393,7 +386,9 @@
url: "/role/list",
dataType: "json",
data: ({
- name: searchName,
+ search: JSON.stringify({
+ name: searchName
+ }),
currentPage: pageNo,
pageSize: pageSize
}),
diff --git a/erp_web/pages/manage/roleFunctions.html b/erp_web/pages/manage/roleFunctions.html
index b0210636..83abbd58 100644
--- a/erp_web/pages/manage/roleFunctions.html
+++ b/erp_web/pages/manage/roleFunctions.html
@@ -48,17 +48,16 @@
}
}
//cnodes = cnodes.substring(0, cnodes.length - 1);
- // pnodes = pnodes.substring(0, pnodes.length - 1);
+ pnodes = pnodes.substring(0, pnodes.length - 1);
if (ctype == 'child') {
return cnodes;
}
- else if("all"){
- return cnodes+pnodes;
- }else{
- return pnodes;
+ else {
+ return pnodes
}
- }
+ ;
+ };
$(function () {
@@ -85,7 +84,7 @@
info: JSON.stringify({
type: type,
keyid: url_id,
- value: GetNode('all')
+ value: GetNode('child')
})
},
dataType: "json",
diff --git a/erp_web/pages/manage/systemConfig.html b/erp_web/pages/manage/systemConfig.html
index f18a35cb..d20b21bd 100644
--- a/erp_web/pages/manage/systemConfig.html
+++ b/erp_web/pages/manage/systemConfig.html
@@ -133,18 +133,12 @@
}
},
{
- title: '操作', field: 'op', width: 160, formatter: function (value, rec,index) {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/6 9:33
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js实现
- */
+ title: '操作', field: 'op', width: 160, formatter: function (value, rec) {
var str = '';
- // var rowInfo = rec.id + 'AaBb' + rec.companyName + 'AaBb' + rec.companyContacts + 'AaBb' + rec.companyAddress
- // + 'AaBb' + rec.companyTel + 'AaBb' + rec.companyFax + 'AaBb' + rec.companyPostCode;
- str += '
编辑 ';
+ var rowInfo = rec.id + 'AaBb' + rec.companyName + 'AaBb' + rec.companyContacts + 'AaBb' + rec.companyAddress
+ + 'AaBb' + rec.companyTel + 'AaBb' + rec.companyFax + 'AaBb' + rec.companyPostCode
+ + 'AaBb' + rec.depotFlag + 'AaBb' + rec.customerFlag;
+ str += '
编辑 ';
str += '
删除 ';
return str;
}
@@ -357,26 +351,26 @@
});
//编辑系统配置信息
- function editSystemConfig(index) {
- // var systemConfigInfo = systemConfigTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
+ function editSystemConfig(systemConfigTotalInfo) {
+ var systemConfigInfo = systemConfigTotalInfo.split("AaBb");
var row = {
- companyName: rowsdata.companyName,
- companyContacts: rowsdata.companyContacts,
- companyAddress: rowsdata.companyAddress,
- companyTel: rowsdata.companyTel,
- companyFax: rowsdata.companyFax,
- companyPostCode: rowsdata.companyPostCode
+ companyName: systemConfigInfo[1],
+ companyContacts: systemConfigInfo[2],
+ companyAddress: systemConfigInfo[3],
+ companyTel: systemConfigInfo[4],
+ companyFax: systemConfigInfo[5],
+ companyPostCode: systemConfigInfo[6]
};
- oldCompanyName = rowsdata.companyName;
+ oldCompanyName = systemConfigInfo[1];
$('#systemConfigDlg').dialog('open').dialog('setTitle', '
编辑系统配置信息');
$(".window-mask").css({width: webW, height: webH});
$('#systemConfigFM').form('load', row);
- systemConfigId = rowsdata.id;
+ systemConfigId = systemConfigInfo[0];
//焦点在名称输入框==定焦在输入文字后面
- $("#companyName").val("").focus().val(rowsdata.companyName);
- url = '/systemConfig/update?id=' + rowsdata.id;
+ $("#companyName").val("").focus().val(systemConfigInfo[1]);
+ $("#depotFlag").attr("checked", systemConfigInfo[7] == '1' ? true : false);
+ $("#customerFlag").attr("checked", systemConfigInfo[8] == '1' ? true : false);
+ url = '/systemConfig/update?id=' + systemConfigInfo[0];
}
//检查系统配置 名称是否存在 ++ 重名无法提示问题需要跟进
diff --git a/erp_web/pages/manage/unit.html b/erp_web/pages/manage/unit.html
index 15429170..7e726a83 100644
--- a/erp_web/pages/manage/unit.html
+++ b/erp_web/pages/manage/unit.html
@@ -110,17 +110,10 @@
{field: 'id', width: 35, align: "center", checkbox: true},
{
title: '操作', field: 'op', align: "center", width: 60,
- formatter: function (value, rec,index) {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/6 9:33
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js实现
- */
+ formatter: function (value, rec) {
var str = '';
- // var rowInfo = rec.id + 'AaBb' + rec.uname;
- str += '
';
+ var rowInfo = rec.id + 'AaBb' + rec.uname;
+ str += '
';
str += '
';
return str;
}
@@ -372,16 +365,15 @@
});
//编辑信息
- function editUnit(index) {
- // var unitInfo = unitTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- oldUnit = rowsdata.uname;
+ function editUnit(unitTotalInfo) {
+ var unitInfo = unitTotalInfo.split("AaBb");
+
+ oldUnit = unitInfo[1];
$('#unitDlg').dialog('open').dialog('setTitle', '
编辑计量单位');
$(".window-mask").css({width: webW, height: webH});
- unitID = rowsdata.id;
+ unitID = unitInfo[0];
//焦点在名称输入框==定焦在输入文字后面
- var name = rowsdata.uname;
+ var name = unitInfo[1];
var basicName = name.substring(0, name.indexOf(",")); //基础单位
$("#basicName").val(basicName);
var otherItem = name.substring(name.indexOf(",") + 1);
@@ -391,7 +383,7 @@
lastNum = lastNum.replace(")", "");
$("#otherNum").val(lastNum);
$("#unitName").text(basicName);
- url = '/unit/update?id=' + rowsdata.id;
+ url = '/unit/update?id=' + unitInfo[0];
}
//检查名称是否存在 ++ 重名无法提示问题需要跟进
diff --git a/erp_web/pages/manage/user.html b/erp_web/pages/manage/user.html
index 340cfccc..217d2ce0 100644
--- a/erp_web/pages/manage/user.html
+++ b/erp_web/pages/manage/user.html
@@ -186,20 +186,13 @@
{title: '描述', field: 'description', width: 130},
{field: 'orgaId',hidden:true, width: 10},
{
- title: '操作', field: 'isystem', width: 150, formatter: function (value, rec,index) {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/6 9:33
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js实现
- */
+ title: '操作', field: 'isystem', width: 150, formatter: function (value, rec) {
var str = '';
- // var rowInfo = rec.id + 'AaBb' + rec.username + 'AaBb' + rec.loginame + 'AaBb' + rec.position
- // + 'AaBb' + rec.orgAbr + 'AaBb' + rec.email + 'AaBb' + rec.phonenum + 'AaBb' + rec.ismanager
- // + 'AaBb' + rec.isystem + 'AaBb' + rec.description+'AaBb'+rec.orgaId+'AaBb'+rec.orgaUserRelId
- // +'AaBb' + rec.userBlngOrgaDsplSeq ;
- str += '
编辑 ';
+ var rowInfo = rec.id + 'AaBb' + rec.username + 'AaBb' + rec.loginame + 'AaBb' + rec.position
+ + 'AaBb' + rec.orgAbr + 'AaBb' + rec.email + 'AaBb' + rec.phonenum + 'AaBb' + rec.ismanager
+ + 'AaBb' + rec.isystem + 'AaBb' + rec.description+'AaBb'+rec.orgaId+'AaBb'+rec.orgaUserRelId
+ +'AaBb' + rec.userBlngOrgaDsplSeq ;
+ str += '
编辑 ';
if (rec.id != rec.tenantId) {
str += '
删除 ';
}
@@ -449,34 +442,32 @@
});
//编辑用户信息
- function editUser(index) {
- // var usernameInfo = usernameTotalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
+ function editUser(usernameTotalInfo) {
+ var usernameInfo = usernameTotalInfo.split("AaBb");
var row = {
- username: rowsdata.username,
- loginame: rowsdata.loginame,
- position: rowsdata.position,
- email: rowsdata.email,
- phonenum: rowsdata.phonenum,
- description: rowsdata.description,
- orgAbr: rowsdata.orgAbr===undefined?'':rowsdata.orgAbr,
- orgaId: rowsdata.orgaId===undefined?'':rowsdata.orgaId,
- orgaUserRelId:rowsdata.orgaUserRelId===undefined?'':rowsdata.orgaUserRelId,
- userBlngOrgaDsplSeq:rowsdata.userBlngOrgaDsplSeq===undefined?'':rowsdata.userBlngOrgaDsplSeq
+ username: usernameInfo[1],
+ loginame: usernameInfo[2],
+ position: usernameInfo[3],
+ email: usernameInfo[5],
+ phonenum: usernameInfo[6],
+ description: usernameInfo[9],
+ orgAbr: usernameInfo[4]=='undefined'?'':usernameInfo[4],
+ orgaId: usernameInfo[10]=='undefined'?'':usernameInfo[10],
+ orgaUserRelId:usernameInfo[11]=='undefined'?'':usernameInfo[11],
+ userBlngOrgaDsplSeq:usernameInfo[12]=='undefined'?'':usernameInfo[12]
};
- oldLoginName = rowsdata.username;
+ oldLoginName = usernameInfo[1];
$('#userDlg').dialog('open').dialog('setTitle', '
编辑用户信息');
$(".window-mask").css({width: webW, height: webH});
$('#usernameFM').form('load', row);
- userID = rowsdata.id;
+ userID = usernameInfo[0];
//焦点在名称输入框==定焦在输入文字后面
- $("#username").val("").focus().val(rowsdata.username);
+ $("#username").val("").focus().val(usernameInfo[1]);
$("#loginame").attr("readonly","readonly");
/**机构选择*/
$("#selectType").val("org");
- url = '/user/updateUser?id=' + rowsdata.id;
+ url = '/user/updateUser?id=' + usernameInfo[0];
}
diff --git a/erp_web/pages/manage/vendor.html b/erp_web/pages/manage/vendor.html
index d5752a12..a4dc328b 100644
--- a/erp_web/pages/manage/vendor.html
+++ b/erp_web/pages/manage/vendor.html
@@ -13,7 +13,7 @@
-
+
diff --git a/erp_web/pages/materials/allocation_out_list.html b/erp_web/pages/materials/allocation_out_list.html
index 4ee7785d..c560241d 100644
--- a/erp_web/pages/materials/allocation_out_list.html
+++ b/erp_web/pages/materials/allocation_out_list.html
@@ -16,7 +16,6 @@
-
diff --git a/erp_web/pages/materials/assemble_list.html b/erp_web/pages/materials/assemble_list.html
index 8c56552f..c104b318 100644
--- a/erp_web/pages/materials/assemble_list.html
+++ b/erp_web/pages/materials/assemble_list.html
@@ -16,7 +16,6 @@
-
diff --git a/erp_web/pages/materials/bill_detail.html b/erp_web/pages/materials/bill_detail.html
index 947a3d27..94d51da9 100644
--- a/erp_web/pages/materials/bill_detail.html
+++ b/erp_web/pages/materials/bill_detail.html
@@ -14,7 +14,7 @@
-
+
diff --git a/erp_web/pages/materials/disassemble_list.html b/erp_web/pages/materials/disassemble_list.html
index c2bb8455..944b88dd 100644
--- a/erp_web/pages/materials/disassemble_list.html
+++ b/erp_web/pages/materials/disassemble_list.html
@@ -16,12 +16,6 @@
-
-
diff --git a/erp_web/pages/materials/material.html b/erp_web/pages/materials/material.html
index d00d0e1f..a886054f 100644
--- a/erp_web/pages/materials/material.html
+++ b/erp_web/pages/materials/material.html
@@ -79,7 +79,7 @@
类别 |
-
+
|
@@ -277,18 +277,14 @@
diff --git a/erp_web/pages/materials/materialProperty.html b/erp_web/pages/materials/materialProperty.html
index 1fd37934..e2225ac7 100644
--- a/erp_web/pages/materials/materialProperty.html
+++ b/erp_web/pages/materials/materialProperty.html
@@ -124,17 +124,10 @@
{title: '排序', field: 'sort', width: 100},
{title: '别名', field: 'anothername', width: 100},
{
- title: '操作', field: 'op', align: "center", width: 80, formatter: function (value, rec,index) {
- /**
- * create by: qiankunpingtai
- * create time: 2019/5/6 9:33
- * website:https://qiankunpingtai.cn
- * description:
- * 修改效率低下的js实现
- */
+ title: '操作', field: 'op', align: "center", width: 80, formatter: function (value, rec) {
var str = '';
- // var rowInfo = rec.id + 'AaBb' + rec.nativename + 'AaBb' + rec.enabled + 'AaBb' + rec.sort + 'AaBb' + rec.anothername;
- str += '
编辑 ';
+ var rowInfo = rec.id + 'AaBb' + rec.nativename + 'AaBb' + rec.enabled + 'AaBb' + rec.sort + 'AaBb' + rec.anothername;
+ str += '
编辑 ';
return str;
}
}
@@ -218,20 +211,19 @@
});
//编辑信息
- function editMaterialProperty(index) {
- // var materialPropertyInfo = totalInfo.split("AaBb");
- //获取当前行
- var rowsdata = $("#tableData").datagrid("getRows")[index];
- $("#nativeName").text(rowsdata.nativename);
- $("#enabled").attr("checked", rowsdata.enabled == true ? true : false);
- $("#sort").val(rowsdata.sort);
- $("#anotherName").val(rowsdata.anothername);
+ function editMaterialProperty(totalInfo) {
+ var materialPropertyInfo = totalInfo.split("AaBb");
+
+ $("#nativeName").text(materialPropertyInfo[1]);
+ $("#enabled").attr("checked", materialPropertyInfo[2] == 'true' ? true : false);
+ $("#sort").val(materialPropertyInfo[3]);
+ $("#anotherName").val(materialPropertyInfo[4]);
$('#materialPropertyDlg').dialog('open').dialog('setTitle', '
编辑商品属性');
$(".window-mask").css({width: webW, height: webH});
//焦点在名称输入框==定焦在输入文字后面
- $("#nativeName").val("").focus().val(rowsdata.nativename);
- url = '/materialProperty/update?id=' + rowsdata.id;
+ $("#nativeName").val("").focus().val(materialPropertyInfo[1]);
+ url = '/materialProperty/update?id=' + materialPropertyInfo[0];
}
//搜索处理
diff --git a/erp_web/pages/materials/material_forselect.html b/erp_web/pages/materials/material_forselect.html
index 9d960c44..2535e1c6 100644
--- a/erp_web/pages/materials/material_forselect.html
+++ b/erp_web/pages/materials/material_forselect.html
@@ -40,188 +40,186 @@
+
-
+