diff --git a/README.md b/README.md
index 683a309c..38d7ae43 100644
--- a/README.md
+++ b/README.md
@@ -1,56 +1,54 @@
-# 华夏ERP完整开源版J2EE代码
-* 很多人说华夏ERP(英文名:jshERP)是目前唯一完整开源的进销存系统
-* 虽然目前只有进销存+财务的功能,但后面将会推出ERP的全部功能,大家一起努力吧
-* 系统初始账号:jsh,密码:123456,部署如有问题请联系QQ:752718920,欢迎加入华夏ERP交流群,群号码:120725710
-* 部署如遇到困难请参考Wiki文档 **https://gitee.com/jishenghua/JSH_ERP/wikis/pages**
-* **本系统演示地址:[http://120.78.214.220:8080](http://120.78.214.220:8080),账号:jsh,密码:123456,都是测试数据,欢迎随意试用**
-
-# 开发初衷
-* 华夏ERP立志为中小企业提供开源好用的ERP软件,降低企业的信息化成本
-* 个人开发者也可以使用华夏ERP进行二次开发,承接外包ERP项目
-* 初学JAVA的小伙伴可以下载源代码来进行学习交流
-
-# 技术框架
-* 核心框架:SpringBoot 1.5.1
-* 持久层框架:Mybatis 1.3.2
-* 日志管理:Log4j 1.2.16
-* JS框架:Jquery 1.8.0
-* UI框架: EasyUI 1.3.5
-* 桌面框架: HoorayOS
-* 项目管理框架: Maven3.2.3
-
-# 开发环境
-建议开发者使用以下环境,可以避免版本带来的问题
-* IDE: MyEclipse8.5+/Eclipse4.4+
-* DB: Mysql5.1
-* JDK: JDK1.7+
-* WEB: Tomcat6.0+
-* Maven: Maven3.2.3+
-* 为方便大家搭建开发环境,分享了下载地址 **http://pan.baidu.com/s/1nuKnlNV**
-
-# 运行环境
-* WEB服务器:Tomcat6.0+
-* 数据库服务器:Mysql5.1
-* JAVA平台: JRE1.7+
-* 操作系统:Windows、Linux等
-
-# 开源说明
-* 本系统100%开源,遵守Apache2.0协议
-
-# 系统美图
-* 零售管理
-
-* 采购管理
-
-* 销售管理
-
-* 仓库管理
-
-* 财务管理
-
-* 报表查询
-
-* 基础数据
-
-* 系统管理
+# 华夏ERP完整开源版J2EE代码
+* 很多人说华夏ERP(英文名:jshERP)是目前唯一完整开源的进销存系统
+* 虽然目前只有进销存+财务的功能,但后面将会推出ERP的全部功能,大家一起努力吧
+* 系统初始账号:jsh,密码:123456,部署如有问题请联系QQ:752718920,欢迎加入华夏ERP交流群,群号码:120725710
+* 部署如遇到困难请参考Wiki文档 **https://gitee.com/jishenghua/JSH_ERP/wikis/pages**
+* **本系统演示地址:[http://120.78.214.220:8080](http://120.78.214.220:8080),账号:jsh,密码:123456,都是测试数据,欢迎随意试用**
+
+# 开发初衷
+* 华夏ERP立志为中小企业提供开源好用的ERP软件,降低企业的信息化成本
+* 个人开发者也可以使用华夏ERP进行二次开发,承接外包ERP项目
+* 初学JAVA的小伙伴可以下载源代码来进行学习交流
+
+# 技术框架
+* 核心框架:SpringBoot 1.5.1
+* 持久层框架:Mybatis 1.3.2
+* 日志管理:Log4j 1.2.16
+* JS框架:Jquery 1.8.0
+* UI框架: EasyUI 1.3.5
+* 桌面框架: HoorayOS 2.0.0
+* 项目管理框架: Maven 3.2.3
+
+# 开发环境
+建议开发者使用以下环境,可以避免版本带来的问题
+* IDE: IntelliJ IDEA 2017+
+* DB: Mysql5.7.4
+* JDK: JDK1.8
+* Maven: Maven3.2.3+
+* 为方便大家搭建开发环境,分享了下载地址 **http://pan.baidu.com/s/1nuKnlNV**
+
+# 运行环境
+* 数据库服务器:Mysql5.7.4
+* JAVA平台: JRE1.8
+* 操作系统:Windows、Linux等
+
+# 开源说明
+* 本系统100%开源,遵守Apache2.0协议
+
+# 系统美图
+* 零售管理
+
+* 采购管理
+
+* 销售管理
+
+* 仓库管理
+
+* 财务管理
+
+* 报表查询
+
+* 基础数据
+
+* 系统管理

\ No newline at end of file
diff --git a/erp_web/js/pages/manage/supplier.js b/erp_web/js/pages/manage/supplier.js
index 08deeb26..bb95183a 100644
--- a/erp_web/js/pages/manage/supplier.js
+++ b/erp_web/js/pages/manage/supplier.js
@@ -1,660 +1,665 @@
- //初始化界面
- $(function() {
- var listTitle = ""; //单据标题
- var listType = ""; //类型
- var listTypeEn = ""; //英文类型
- getType();
- initTableData();
- ininPager();
- bindEvent();
- });
-
- //根据名称获取类型
- function getType(){
- listTitle = $("#tablePanel").prev().text();
- if(listTitle === "供应商信息列表"){
- listType = "供应商";
- listTypeEn = "Vendor";
- }
- else if(listTitle === "客户信息列表"){
- listType = "客户";
- listTypeEn = "Customer";
- }
- else if(listTitle === "会员信息列表"){
- listType = "会员";
- listTypeEn = "Member";
- }
- }
-
- //初始化表格数据
- 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)
- {
- 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(supplierInfo) {
- $.messager.confirm('删除确认','确定要删除此条信息吗?',function(r) {
- if (r) {
- var supplierTotalInfo = supplierInfo.split("AaBb");
- $.ajax({
- type:"post",
- url: "/supplier/" + supplierTotalInfo[0] + "/delete",
- dataType: "json",
- success: function (res) {
- if(res && res.code == 200) {
- $("#searchBtn").click();
- } 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/batchDelete",
- 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;
- }
- });
- }
- });
- }
- }
-
- //批量启用
- 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(){
- window.location.href = "/supplier/exportExcel.action?browserType=" + getOs() + "&type=" + listTypeEn;
- }
-
- //增加单位
- 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 (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(supplierTotalInfo) {
- var supplierInfo = supplierTotalInfo.split("AaBb");
- var row = {
- supplier : supplierInfo[1],
- contacts : supplierInfo[2].replace("undefined",""),
- phonenum : supplierInfo[3].replace("undefined",""),
- email : supplierInfo[4].replace("undefined",""),
- BeginNeedGet : supplierInfo[5],
- BeginNeedPay : supplierInfo[6],
- AllNeedGet: "",
- AllNeedPay: "",
- description : supplierInfo[8].replace("undefined",""),
- type : supplierInfo[9],
- fax : supplierInfo[10].replace("undefined",""),
- telephone : supplierInfo[11].replace("undefined",""),
- address : supplierInfo[12].replace("undefined",""),
- taxNum : supplierInfo[13].replace("undefined",""),
- bankName : supplierInfo[14].replace("undefined",""),
- accountNumber : supplierInfo[15].replace("undefined",""),
- taxRate : supplierInfo[16].replace("undefined","")
- };
- oldSupplier = supplierInfo[1];
- $('#supplierDlg').dialog('open').dialog('setTitle','
编辑'+listType +"信息");
- $(".window-mask").css({ width: webW ,height: webH});
- $('#supplierFM').form('load',row);
- supplierID = supplierInfo[0];
- //焦点在名称输入框==定焦在输入文字后面
- $("#supplier").val("").focus().val(supplierInfo[1]);
- url = '/supplier/update?id=' + supplierInfo[0];
-
- //显示累计应收和累计应付
- var thisDateTime = getNowFormatDateTime(); //当前时间
- var supType = "customer";
- if(listType === "客户"){
- supType = "customer"
- }
- else if(listType === "供应商"){
- supType = "vendor"
- }
- $.ajax({
- type:"get",
- url: "/depotHead/findTotalPay",
- dataType: "json",
- async: false,
- data: ({
- supplierId: supplierInfo[0],
- 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: supplierInfo[0],
- 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;
- }
- });
- }
-
+ //初始化界面
+ $(function() {
+ var listTitle = ""; //单据标题
+ var listType = ""; //类型
+ var listTypeEn = ""; //英文类型
+ getType();
+ initTableData();
+ ininPager();
+ bindEvent();
+ });
+
+ //根据名称获取类型
+ function getType(){
+ listTitle = $("#tablePanel").prev().text();
+ if(listTitle === "供应商信息列表"){
+ listType = "供应商";
+ listTypeEn = "Vendor";
+ }
+ else if(listTitle === "客户信息列表"){
+ listType = "客户";
+ listTypeEn = "Customer";
+ }
+ else if(listTitle === "会员信息列表"){
+ listType = "会员";
+ listTypeEn = "Member";
+ }
+ }
+
+ //初始化表格数据
+ 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)
+ {
+ 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(supplierInfo) {
+ $.messager.confirm('删除确认','确定要删除此条信息吗?',function(r) {
+ if (r) {
+ var supplierTotalInfo = supplierInfo.split("AaBb");
+ $.ajax({
+ type:"post",
+ url: "/supplier/" + supplierTotalInfo[0] + "/delete",
+ dataType: "json",
+ success: function (res) {
+ if(res && res.code == 200) {
+ $("#searchBtn").click();
+ } 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/batchDelete",
+ 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;
+ }
+ });
+ }
+ });
+ }
+ }
+
+ //批量启用
+ 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());
+ window.location.href = "/supplier/exportExcel?browserType=" + getOs()
+ + "&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 (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(supplierTotalInfo) {
+ var supplierInfo = supplierTotalInfo.split("AaBb");
+ var row = {
+ supplier : supplierInfo[1],
+ contacts : supplierInfo[2].replace("undefined",""),
+ phonenum : supplierInfo[3].replace("undefined",""),
+ email : supplierInfo[4].replace("undefined",""),
+ BeginNeedGet : supplierInfo[5],
+ BeginNeedPay : supplierInfo[6],
+ AllNeedGet: "",
+ AllNeedPay: "",
+ description : supplierInfo[8].replace("undefined",""),
+ type : supplierInfo[9],
+ fax : supplierInfo[10].replace("undefined",""),
+ telephone : supplierInfo[11].replace("undefined",""),
+ address : supplierInfo[12].replace("undefined",""),
+ taxNum : supplierInfo[13].replace("undefined",""),
+ bankName : supplierInfo[14].replace("undefined",""),
+ accountNumber : supplierInfo[15].replace("undefined",""),
+ taxRate : supplierInfo[16].replace("undefined","")
+ };
+ oldSupplier = supplierInfo[1];
+ $('#supplierDlg').dialog('open').dialog('setTitle','
编辑'+listType +"信息");
+ $(".window-mask").css({ width: webW ,height: webH});
+ $('#supplierFM').form('load',row);
+ supplierID = supplierInfo[0];
+ //焦点在名称输入框==定焦在输入文字后面
+ $("#supplier").val("").focus().val(supplierInfo[1]);
+ url = '/supplier/update?id=' + supplierInfo[0];
+
+ //显示累计应收和累计应付
+ var thisDateTime = getNowFormatDateTime(); //当前时间
+ var supType = "customer";
+ if(listType === "客户"){
+ supType = "customer"
+ }
+ else if(listType === "供应商"){
+ supType = "vendor"
+ }
+ $.ajax({
+ type:"get",
+ url: "/depotHead/findTotalPay",
+ dataType: "json",
+ async: false,
+ data: ({
+ supplierId: supplierInfo[0],
+ 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: supplierInfo[0],
+ 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/materials/in_out.js b/erp_web/js/pages/materials/in_out.js
index bffab1fb..8bc125d1 100644
--- a/erp_web/js/pages/materials/in_out.js
+++ b/erp_web/js/pages/materials/in_out.js
@@ -1,2974 +1,2962 @@
- //初始化界面
- var kid = sessionStorage.getItem("userId");
- 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 depotHeadMaxId=null; //获取最大的Id
- var accepId=null; //保存的主表id
- var url;
- var depotHeadID = 0;
- var preTotalPrice = 0; //前一次加载的金额
- var orgDepotHead = "";
- var editIndex = undefined;
- var listTitle = ""; //单据标题
- var listType = ""; //入库 出库
- var listSubType = ""; //采购 销售等
- var payTypeTitle = "";//付款 收款
- var organUrl = ""; //组织数据接口地址
- var amountNum = ""; //单据编号开头字符
- var depotString = ""; //店铺id列表
- var orgDefaultId = 0; //单位默认编号
- 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
- $(function(){
- //初始化系统基础信息
- getType();
- initSystemData_UB();
- initSelectInfo_UB();
- initSystemData_depot();
- initSelectInfo_depot();
- initSystemData_person();
- initSelectInfo_person();
- initSystemData_account();
- initSelectInfo_account();
- initSupplier(); //供应商
- initSalesman(); //销售人员
- initGift(); //初始化礼品卡
- initOutItemList(); //初始化支出项目
- initMProperty(); //初始化商品属性
- initTableData();
- ininPager();
- initForm();
- bindEvent();//绑定操作事件
- });
- //根据单据名称获取类型
- function getType(){
- listTitle = $("#tablePanel").prev().text();
- depotString = "|";
- //改变宽度和高度
- $("#searchPanel").panel({width:webW-2});
- $("#tablePanel").panel({width:webW-2});
- var supUrl = "/supplier/findBySelect_sup"; //供应商接口
- var cusUrl = "/supplier/findBySelect_cus?UBType=UserCustomer&UBKeyId=" + kid; //客户接口
- var retailUrl = "/supplier/findBySelect_retail"; //散户接口
- if(listTitle === "采购入库列表"){
- listType = "入库";
- listSubType = "采购";
- payTypeTitle = "付款";
- organUrl = supUrl;
- amountNum = "CGRK";
- }
- else if(listTitle === "零售退货列表"){
- listType = "入库";
- listSubType = "零售退货"; //注:用预付款购买的产品不能退货
- payTypeTitle = "付款";
- organUrl = retailUrl;
- amountNum = "LSTH";
- }
- else if(listTitle === "销售退货列表"){
- listType = "入库";
- listSubType = "销售退货";
- payTypeTitle = "付款";
- organUrl = cusUrl;
- amountNum = "XSTH";
- }
- else if(listTitle === "其它入库列表"){
- listType = "入库";
- listSubType = "其它";
- payTypeTitle = "隐藏";
- organUrl = supUrl;
- amountNum = "QTRK";
- }
- else if(listTitle === "零售出库列表"){
- listType = "出库";
- listSubType = "零售";
- payTypeTitle = "收款";
- organUrl = retailUrl;
- amountNum = "LSCK";
- }
- else if(listTitle === "销售出库列表"){
- listType = "出库";
- listSubType = "销售";
- payTypeTitle = "收款";
- organUrl = cusUrl;
- amountNum = "XSCK";
- }
- else if(listTitle === "采购退货列表"){
- listType = "出库";
- listSubType = "采购退货";
- payTypeTitle = "收款";
- organUrl = supUrl;
- amountNum = "CGTH";
- }
- else if(listTitle === "其它出库列表"){
- listType = "出库";
- listSubType = "其它";
- payTypeTitle = "隐藏";
- organUrl = cusUrl;
- amountNum = "QTCK";
- }
- else if(listTitle === "调拨出库列表"){
- listType = "出库";
- listSubType = "调拨";
- payTypeTitle = "隐藏";
- organUrl = supUrl;
- amountNum = "DBCK";
- }
- else if(listTitle === "礼品充值列表"){
- listType = "出库";
- listSubType = "礼品充值";
- payTypeTitle = "隐藏";
- organUrl = supUrl;
- amountNum = "LPCZ";
- }
- else if(listTitle === "礼品销售列表"){
- listType = "出库";
- listSubType = "礼品销售";
- payTypeTitle = "隐藏";
- organUrl = supUrl;
- amountNum = "LPXS";
- }
- else if(listTitle === "组装单列表"){
- listType = "其它";
- listSubType = "组装单";
- payTypeTitle = "隐藏";
- organUrl = supUrl;
- amountNum = "ZZD";
- }
- else if(listTitle === "拆卸单列表"){
- listType = "其它";
- listSubType = "拆卸单";
- payTypeTitle = "隐藏";
- organUrl = supUrl;
- amountNum = "CSD";
- }
- }
- //初始化系统基础信息
- 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)
- {
- 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;
- }
- }
- if(listSubType === "零售"){
- orgDefaultList = res;
- }
- },
- onSelect: function(rec){
- if(listSubType === "零售"){
- var option = "";
- if(rec.supplier !== "非会员" && rec.advanceIn >0){
- option = '';
- option += '';
- }
- else {
- option += '';
- }
- $("#payType").empty().append(option);
- }
- else{
- $.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 initGift(){
- if(listSubType == "礼品充值"|| listSubType == "礼品销售"){
- $('#GiftId').combobox({
- url: "/depot/findGiftByType?type=1",
- valueField:'id',
- textField:'name'
- });
- $('#searchGiftId').combobox({
- url: "/depot/findGiftByType?type=1",
- valueField:'id',
- textField:'name'
- });
- }
- if(listSubType == "礼品销售"){
- $.ajax({
- type:"post",
- url: "/supplier/findBySelectRetailNoPeople.action", //散户接口
- dataType: "json",
- success: function (res){
- if(res && res[0]){
- orgDefaultId = res[0].id;
- }
- }
- });
- }
- }
-
- //初始化收入项目列表
- 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(){
- 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为显示
- if(listSubType == "调拨" || listSubType == "其它" || listSubType == "零售" || listSubType == "零售退货" || listSubType == "礼品充值" || listSubType == "礼品销售" || listSubType == "组装单" || listSubType == "拆卸单"){
- isShowLastMoneyColumn = true; //隐藏
- }
- var isShowOrganNameColumn = false; //是否显示供应商、客户等信息,true为隐藏,false为显示
- var organNameTitle = ""; //组织名称标题
- if(listSubType == "调拨" || listSubType == "礼品充值" || listSubType == "礼品销售" || listSubType == "组装单" || listSubType == "拆卸单"){
- isShowOrganNameColumn = true; //隐藏
- }
- else {
- if(listTitle == "采购入库列表" || listTitle == "采购退货列表" || listTitle == "其它入库列表"){
- organNameTitle = "供应商名称";
- }
- else if(listTitle == "销售退货列表" || listTitle == "销售出库列表" || listTitle == "其它出库列表"){
- organNameTitle = "客户名称";
- }
- else if(listTitle == "零售出库列表" || listTitle == "零售退货列表"){
- organNameTitle = "会员卡号";
- }
- }
- $('#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:90,
- formatter:function(value,rec) {
- var str = '';
- var rowInfo = rec.id + 'AaBb' + rec.projectid+ 'AaBb' + rec.number+ 'AaBb' + rec.operpersonname
- + 'AaBb' + rec.opertime+ 'AaBb' + rec.organid+ 'AaBb' + rec.handspersonid
- + 'AaBb' + rec.accountid+ 'AaBb' + rec.changeamount+ 'AaBb' + rec.remark
- + 'AaBb' + rec.projectName+ 'AaBb' + rec.organName+ 'AaBb' + rec.handsPersonName
- + 'AaBb' + rec.accountName + 'AaBb' + rec.totalprice + 'AaBb' + rec.allocationprojectid
- + 'AaBb' + rec.allocationProjectName + 'AaBb' + rec.paytype + 'AaBb' + rec.salesman
- + 'AaBb' + rec.discount + 'AaBb' + rec.discountmoney + 'AaBb' + rec.discountlastmoney
- + 'AaBb' + rec.accountidlist + 'AaBb' + rec.accountmoneylist
- + 'AaBb' + rec.othermoney + 'AaBb' + rec.othermoneylist + 'AaBb' + rec.othermoneyitem + 'AaBb' + rec.accountday;
- var orgId = rec.organid? rec.organid:0;
- str += '
';
- str += '
';
- str += '
';
- return str;
- }
- },
- { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
- { title: '单据编号',field: 'number',width:130},
- { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
- if(value) {
- return value.replace(",",",");
- }
- }
- },
- { title: '单据日期 ',field: 'opertime',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){
- return value? "已审核":"未审核";
- }
- }
- ]],
- 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("("));
- }
- var unitArr = unitName.split(",");
- var basicUnit = unitArr[0]; //基础单位
- var otherUnit = unitArr[1]; //副单位
- var unitSetInput =""; //单位
- if(listSubType === "采购" || listSubType === "采购退货"){
- unitSetInput = rec.data[0].firstinunit;
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = thisRatio;
- }
- }
- else if(listSubType === "销售" || listSubType === "销售退货" || listTitle == "礼品充值" || listTitle == "礼品销售" || listSubType === "零售" || listSubType === "零售退货"){
- 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,
- monthTime: monthTime,
- currentPage: 1,
- pageSize: 10
- },
- 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.rows[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)); //本次欠款
-
- if(listSubType == "零售" || listSubType == "零售退货") {
- $("#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 = "";
- if(listSubType == "调拨"){
- isShowAnotherDepot = false; //调拨时候显示对方仓库
- anotherDepotHeadName = "调入仓库";
- anotherDepotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- anotherDepotTextField = "depotName";
- }
- if(listSubType == "礼品充值"){
- isShowAnotherDepot = false; //礼品充值时候显示礼品卡
- anotherDepotHeadName = "礼品卡";
- anotherDepotUrl = "/depot/findGiftByType.action?type=1";
- anotherDepotTextField = "name";
- }
- if(listSubType == "礼品销售"){
- depotHeadName = "礼品卡";
- depotUrl = "/depot/findGiftByType.action?type=1";
- depotTextField = "name";
- }
- else {
- depotHeadName = "仓库名称";
- depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
- depotTextField = "depotName";
- }
- var isShowTaxColumn = false; //是否显示税率相关的列,true为隐藏,false为显示
- if(listSubType == "调拨" || listSubType == "其它" || listSubType == "零售" || listSubType == "零售退货" || listSubType == "礼品充值" || listSubType == "礼品销售" || listSubType == "组装单" || listSubType == "拆卸单"){
- isShowTaxColumn = true; //隐藏
- }
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- if(listSubType == "组装单" || listSubType == "拆卸单"){
- isShowMaterialTypeColumn = 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;
- if(unitName) {
- ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
- unitName = unitName.substring(0, unitName.indexOf("("));
- }
- var unitArr = unitName.split(",");
- var basicUnit = unitArr[0]; //基础单位
- var otherUnit = unitArr[1]; //副单位
- var unitSetInput =""; //单位
- body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
- var loadRatio = 1; //在单位输入框上面加载比例字段
- if(listSubType === "采购" || listSubType === "采购退货"){
- unitSetInput = res.data[0].firstinunit; //给单位文本框赋值
- if(basicUnit==unitSetInput){ //基础单位等于选择的单位
- loadRatio = 1;
- }
- else if(otherUnit==unitSetInput){ //副单位等于选择的单位
- loadRatio = ratio;
- }
- }
- else if(listSubType === "销售" || listSubType === "销售退货" || listSubType === "礼品充值" || listSubType === "礼品销售" || listSubType === "零售" || listSubType === "零售退货"){
- 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"){
- if(listTitle == "采购入库列表" || listTitle == "销售退货列表" || listTitle == "其它入库列表") {
- UnitPrice = basicPresetPriceOne;
- }
- else if(listTitle == "销售出库列表" || listTitle == "采购退货列表" || listTitle == "其它出库列表" || listTitle == "调拨出库列表" || listTitle == "礼品充值列表" || listTitle == "礼品销售列表") {
- UnitPrice = basicPresetPriceTwo;
- }
- else if(listTitle == "零售出库列表" || listTitle == "零售退货列表"){
- UnitPrice = retailPriceOne;
- }
- body.find("[field='Stock']").find(input).val(stock); //修改库存
- }
- else if(type === "other"){
- if(listTitle == "采购入库列表" || listTitle == "销售退货列表" || listTitle == "其它入库列表") {
- UnitPrice = otherPresetPriceOne;
- }
- else if(listTitle == "销售出库列表" || listTitle == "采购退货列表" || listTitle == "其它出库列表" || listTitle == "调拨出库列表" || listTitle == "礼品充值列表" || listTitle == "礼品销售列表") {
- UnitPrice = otherPresetPriceTwo;
- }
- else if(listTitle == "零售出库列表" || listTitle == "零售退货列表"){
- 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(listSubType == "零售" || listSubType == "零售退货") {
- if(res.data[0].unit) { //如果存在计量单位信息
- detailPrice = retailPrice;
- }
- else {
- if (firstOutUnit == basicUnit) {
- detailPrice = retailPriceOne;
- }
- else if (firstOutUnit == otherUnit) {
- detailPrice = retailPriceTwo;
- }
- }
- }
- else if(listTitle == "采购入库列表" || listTitle == "销售退货列表" || listTitle == "其它入库列表") {
- if(res.data[0].unit) { //如果存在计量单位信息
- detailPrice = presetPriceOne;
- }
- else {
- if (firstInUnit == basicUnit) {
- detailPrice = basicPresetPriceOne;
- }
- else if (firstInUnit == otherUnit) {
- detailPrice = otherPresetPriceOne;
- }
- }
- }
- else if(listTitle == "销售出库列表" || listTitle == "采购退货列表" || listTitle == "其它出库列表" || listTitle == "调拨出库列表" || listTitle == "礼品充值列表" || listTitle == "礼品销售列表") {
- 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()
- {
- removeit(); //删除
- }
- },
- {
- 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);
- }
- },
- error:function() {
- $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
- }
- });
- }
-
- //初始化表格数据-商品列表-查看状态
- function initTableData_material_show(TotalPrice){
- var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
- var anotherDepotHeadName = ""; //对方仓库的列的标题
- var depotHeadName = ""; //仓库的列的标题
- if(listSubType == "调拨"){
- isShowAnotherDepot = false; //调拨时候显示对方仓库
- anotherDepotHeadName = "调入仓库";
- }
- if(listSubType == "礼品充值"){
- isShowAnotherDepot = false; //礼品充值时候显示礼品卡
- anotherDepotHeadName = "礼品卡";
- }
- if(listSubType == "礼品销售"){
- depotHeadName = "礼品卡";
- }
- else {
- depotHeadName = "仓库名称";
- }
- var isShowTaxColumn = false; //是否显示税率相关的列,true为隐藏,false为显示
- if(listSubType == "调拨" || listSubType == "其它" || listSubType == "零售" || listSubType == "零售退货" || listSubType == "礼品充值" || listSubType == "礼品销售" || listSubType == "组装单" || listSubType == "拆卸单"){
- isShowTaxColumn = true; //隐藏
- }
- var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
- if(listSubType == "组装单" || listSubType == "拆卸单"){
- isShowMaterialTypeColumn = 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) {
- $.messager.alert('删除提示','已审核的单据不能删除!','warning');
- return;
- }
- $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
- if (r) {
- $.ajax({
- type:"post",
- url: "/depotHead/" + depotHeadID + "/delete",
- dataType: "json",
- 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 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;
- }
- //alert(row[i].id);
- ids += row[i].id + ",";
- }
- //批量更新会员的预收款信息
- for(var i = 0;i < row.length; i ++) {
- if(listSubType === "零售") {
- $.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",
- 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;
- }
- });
- }
- });
- }
- }
-
- //批量审核
- 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)
- {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: true,
- 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;
- }
- });
- }
- });
- }
- }
-
- //批量反审核
- 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)
- {
- ids += row[i].id;
- break;
- }
- ids += row[i].id + ",";
- }
- $.ajax({
- type:"post",
- url: "/depotHead/batchSetStatus",
- dataType: "json",
- async : false,
- data: ({
- status: false,
- 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;
- }
- });
- }
- });
- }
- }
-
- //新增信息
- function addDepotHead(){
- $("#clientIp").val(clientIp);
- $('#depotHeadFM').form('clear');
- var thisDateTime = getNowFormatDateTime(); //当前时间
- $("#OperTime").val(thisDateTime);
- var thisNumber = getNowFormatDateNum(); //根据时间生成编号
- var thisDate = getNowFormatDate(); //当前日期
- var beginTime = thisDate + " 00:00:00";
- var endTime = thisDate + " 23:59:59";
- //生成单据编号
- $.ajax({
- type: "get",
- url: "/depotHead/buildNumber",
- data: {
- type: listType,
- subType: listSubType,
- beginTime: beginTime,
- endTime: endTime
- },
- success:function(res){
- if(res && res.code === 200){
- var obj = res.data;
- var defaultNumber = obj.DefaultNumber;
- var thisDateTwo = getNowFormatDateTwo(); //当前日期
- var newNumber = amountNum + thisDateTwo + defaultNumber
- $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
- }
- },
- error:function(){
- $.messager.alert('提示','生成单据编号失败!','error');
- }
- });
- //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为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','
增加供应商');
- });
- url = '/depotHead/add';
-
- //零售单据修改收款时,自动计算找零
- if(listSubType == "零售" || listSubType == "零售退货") {
- $("#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(depotHeadTotalInfo, status){
- if(status) {
- $.messager.alert('编辑提示','已审核的单据不能编辑!','warning');
- return;
- }
- var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- $("#clientIp").val(clientIp);
- if(listSubType==="礼品销售"){
- $("#GiftId").combobox('setValue',depotHeadInfo[1]);
- }
- else{
- $("#ProjectId").focus().val(depotHeadInfo[1]);
- }
- var ProjectId=depotHeadInfo[1];
- if(ProjectId!='')
- {
- initSystemData_person(ProjectId);
- initSelectInfo_person();
- }
- $("#Number").val(depotHeadInfo[2]).attr("data-defaultNumber",depotHeadInfo[2]);
- $("#OperTime").val(depotHeadInfo[4]);
- $('#OrganId').combobox('setValue', depotHeadInfo[5]);
- $("#HandsPersonId").val(depotHeadInfo[6]);
- $("#AccountId").val(depotHeadInfo[7]);
- $("#ChangeAmount").val(depotHeadInfo[8]);
- $("#ChangeAmount").attr("data-changeamount", depotHeadInfo[8]);
- $("#Remark").val(depotHeadInfo[9]);
- $("#Discount").val(depotHeadInfo[19]);
- $("#DiscountMoney").val(depotHeadInfo[20]);
- $("#DiscountLastMoney").val(depotHeadInfo[21]);
- $("#Debt").val((depotHeadInfo[21]-depotHeadInfo[8]).toFixed(2));
- $("#AccountDay").val(depotHeadInfo[27].replace("undefined","")); //结算天数
- var TotalPrice = depotHeadInfo[14];
- preTotalPrice = depotHeadInfo[14]; //记录前一次合计金额,用于扣预付款
- $("#AllocationProjectId").val(depotHeadInfo[15]);
- if(listSubType==="礼品充值"){
- $("#GiftId").combobox('setValue', depotHeadInfo[15]);
- }
- oldNumber = depotHeadInfo[2]; //记录编辑前的单据编号
- oldId = depotHeadInfo[0]; //记录单据Id
- var editTitle = listTitle.replace("列表","信息");
- $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
- $(".window-mask").css({ width: webW ,height: webH});
- depotHeadID = depotHeadInfo[0];
-
- if(listSubType == "零售"){
- var option = "";
- if(depotHeadInfo[17] === "预付款"){
- option = '';
- option += '';
- }
- else {
- option += '';
- }
- $("#payType").empty().append(option);
- }
-
- if(listSubType === "销售" || listSubType === "销售退货"){
- if(depotHeadInfo[18]){
- var arr = depotHeadInfo[18].split(",");
- var salesmanArray = [];
- for(var i=0;i",""));
- }
- }
- $("#Salesman").combobox('setValues', salesmanArray);
- }
- }
-
- //采购入库、销售出库的多账户加载
- if(depotHeadInfo[22]!="undefined" && depotHeadInfo[23]!="undefined"){
- $("#AccountId").val("many"); //下拉框选中多账户
- var accountArr = depotHeadInfo[22].split(",");
- var accountMoneyArr = depotHeadInfo[23].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(depotHeadInfo[25] && depotHeadInfo[26]){
- $("#OtherMoney").val(depotHeadInfo[24].replace("undefined","0")); //采购费用、销售费用
- var itemArr = depotHeadInfo[25].split(",");
- var itemMoneyArr = depotHeadInfo[26].split(",");
- $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
- }
-
- initTableData_material("edit",TotalPrice); //商品列表
- reject(); //撤销下、刷新商品列表
- url = '/depotHead/update?id=' + depotHeadInfo[0];
- }
-
- //查看信息
- function showDepotHead(depotHeadTotalInfo){
- var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
- var manyAccountMoney = 0; //多账户合计-零售
- $("#ProjectIdShow").text(depotHeadInfo[10]);
- $("#NumberShow").text(depotHeadInfo[2]);
- $("#OperTimeShow").text(depotHeadInfo[4]);
- $('#OrganIdShow').text(depotHeadInfo[11]);
- $("#HandsPersonIdShow").text(depotHeadInfo[12]);
- if(depotHeadInfo[13]){
- $("#AccountIdShow").text(depotHeadInfo[13]); //结算账户
- }
- else if(depotHeadInfo[22] && depotHeadInfo[23]){
- var accountArr = depotHeadInfo[22].split(","); //账户id列表
- var accountMoneyArr = depotHeadInfo[23].split(","); //账户金额列表
- var accountIdShow = "";
- for(var j =0;j 查看' + showTitle);
- $(".window-mask").css({ width: webW ,height: webH});
-
- depotHeadID = depotHeadInfo[0];
- initTableData_material_show(TotalPrice); //商品列表-查看状态
-
- //零售单据展示数据
- if(listSubType == "零售" || listSubType == "零售退货"){
- 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);
- }
- }
- if(listSubType === "销售" || listSubType === "销售退货"){
- if(depotHeadInfo[18]){
- var arr = depotHeadInfo[18].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;
- }
- //保存信息
- $("#saveDepotHead").off("click").on("click",function(){
- if(!$('#depotHeadFM').form('validate')){
- return;
- }
- else {
- //如果初始编号被修改了,就要判断单据编号是否存在
- if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
- //调用查询单据编号是否重名的方法
- if(checkDepotHeadNumber()){
- return;
- }
- }
- //输入框提示
- if(listTitle === "采购入库列表"){
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择供应商!','warning');
- return;
- }
- if(!$('#AccountId').val()){
- $.messager.alert('提示','请选择结算账户!','warning');
- return;
- }
- }
- else if(listTitle === "零售退货列表"){
- if(!$('#AccountId').val()){
- $.messager.alert('提示','请选择付款账户!','warning');
- return;
- }
- if($("#AccountId").val() == "many" && $("#backAmount").val()-0 >0) {
- $.messager.alert('提示', '选择多账户时的找零金额不能大于0!', 'warning');
- return;
- }
- }
- else if(listTitle === "销售退货列表"){
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择退货单位!','warning');
- return;
- }
- if(!$('#AccountId').val()){
- $.messager.alert('提示','请选择付款账户!','warning');
- return;
- }
- }
- else if(listTitle === "其它入库列表"){
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择往来单位!','warning');
- return;
- }
- }
- else if(listTitle === "零售出库列表"){
- 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;
- }
- }
- else if(listTitle === "销售出库列表"){
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择购买单位!','warning');
- return;
- }
- if(!$('#AccountId').val()){
- $.messager.alert('提示','请选择收款账户!','warning');
- return;
- }
- }
- else if(listTitle === "采购退货列表"){
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择收货单位!','warning');
- return;
- }
- if(!$('#AccountId').val()){
- $.messager.alert('提示','请选择收款账户!','warning');
- return;
- }
- }
- else if(listTitle === "其它出库列表"){
- if(!$('#OrganId').combobox('getValue')){
- $.messager.alert('提示','请选择往来单位!','warning');
- return;
- }
- }
- else if(listTitle === "调拨出库列表"){
-
- }
- //进行明细的校验
- 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(","); //转为数组
- }
- if(listSubType === "采购"||listSubType === "零售退货"||listSubType === "销售退货"){
- //付款为负数
- ChangeAmount = 0 - ChangeAmount;
- TotalPrice = 0 - TotalPrice;
- if(accountMoneyArr) {
- accountMoneyArr = changeListFmtMinus(accountMoneyArr); //将数组单个金额中的数值转为负数
- }
- }
- //零售时候,可以从会员预付款中扣款
- var thisPayType = "现付";
- if(listSubType === "零售") {
- if($("#payType").val() ==="预付款") {
- thisPayType = "预付款";
- }
- }
- var SalesmanStr = "";
- if(listSubType === "销售" || listSubType === "销售退货"){
- 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;
- }
- $.ajax({
- type:"post",
- url: url,
- dataType: "json",
- async : false,
- data: ({
- info : JSON.stringify({
- Type: listType,
- SubType: listSubType,
- ProjectId: ProjectId,
- AllocationProjectId: AllocationProjectId,
- DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
- Number: $.trim($("#Number").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() //结算天数
- })
- }),
- success: function (tipInfo)
- {
- if(tipInfo)
- {
- function closeDialog(){
- $('#depotHeadDlg').dialog('close');
- var opts = $("#tableData").datagrid('options');
- showDepotHeadDetails(opts.pageNumber,opts.pageSize);
- }
-
- if(thisPayType === "预付款") {
- //更新用户信息-预付款
- var advanceIn = 0; //预付款金额
- if(depotHeadID){
- advanceIn = TotalPrice - preTotalPrice; //修改时,预付款=合计金额-加载金额
- }
- else{
- advanceIn = TotalPrice; //新增时,预付款=合计金额
- }
- $.ajax({
- type:"post",
- url: "/supplier/updateAdvanceIn",
- dataType: "json",
- data:{
- supplierId: OrganId, //会员id
- advanceIn: 0 - advanceIn //保存的同时扣掉用户的预付款
- },
- success: function(res){
- if(res && res.code === 200) {
- //保存会员预收款成功
- }
- },
- error: function(){
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
- }
-
- //保存明细记录
- if(depotHeadID ==0)
- {
- getMaxId(); //查找最大的Id
- accept(depotHeadMaxId,closeDialog); //新增
- }
- else
- {
- accept(depotHeadID,closeDialog); //修改
- }
- }
- else
- {
- $.messager.show({
- title: '错误提示',
- msg: '保存信息失败,请稍后重试!'
- });
- }
- },
- //此处添加错误处理
- error:function()
- {
- $.messager.alert('提示','保存信息异常,请稍后再试!','error');
- return;
- }
- });
- }
- });
-
- //初始化键盘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数据存储
- }
- if(listSubType==="零售" || listSubType==="零售退货") {
- $("#getAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
- var backAmount = $("#getAmount").val() - $("#ChangeAmount").val();
- $("#backAmount").val((backAmount - 0).toFixed(2)); //计算找零金额
- }
- else {
- $("#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"); //将下拉置空并把缓存参数清空
- if(listSubType==="零售" || listSubType==="零售退货"){
- $("#ChangeAmount").prop("readonly","readonly");
- }
- else {
- $("#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"); //将下拉置空并把缓存参数清空
- if(listSubType==="零售" || listSubType==="零售退货"){
- $("#ChangeAmount").prop("readonly","readonly");
- }
- else {
- $("#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]);
- });
- if(listSubType==="零售" || listSubType==="零售退货") {
- $("#accountMoneyTotalDlg").text($("#getAmount").val());
- }
- else {
- $("#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());
- });
-
- if(listTitle === "采购入库列表"){
- //检查单位名称是否存在 ++ 重名无法提示问题需要跟进
- 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(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';
- $.ajax({
- url: url,
- type:"post",
- dataType: "json",
- data:{
- supplier:$("#supplier").val(),
- type: "供应商",
- contacts:$("#contacts").val(),
- phonenum:$("#phonenum").val(),
- telephone:$("#telephone").val(),
- email:$("#email").val(),
- address:$("#address").val(),
- fax:$("#fax").val(),
- BeginNeedGet:$("#BeginNeedGet").val(),
- BeginNeedPay:$("#BeginNeedPay").val(),
- taxNum:$("#taxNum").val(),
- taxRate:$("#taxRate").val(),
- bankName:$("#bankName").val(),
- accountNumber:$("#accountNumber").val(),
- description:$("#description").val(),
- enabled:1,
- clientIp: clientIp
- },
- success: function(res) {
- if (res) {
- $('#supplierDlg').dialog('close');
- initSupplier(); //刷新供应商
- }
- }
- });
- });
- }
- }
-
- function showDepotHeadDetails(pageNo,pageSize){
- var materialParam = $.trim($("#searchMaterial").val());
- $.ajax({
- type:"get",
- url: "/depotItem/getHeaderIdByMaterial",
- dataType: "json",
- data: ({
- materialParam: materialParam,
- depotIds: depotString
- }),
- success: function (res) {
- if(res && res.code === 200) {
- var ids = res.data;
- if(ids){
- $.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: $("#searchBeginTime").val(),
- endTime: $("#searchEndTime").val(),
- dhIds: ids
- }),
- 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;
- }
- });
- }
- else {
- $("#tableData").datagrid('loadData', []);
- }
- }
- },
- //此处添加错误处理
- 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 = "普通子件";
- }
- if(listSubType == "组装单" || listSubType == "拆卸单"){
- 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', {});
- editIndex = $('#materialData').datagrid('getRows').length - 1;
- $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
- autoReckon();
- }
- }
- //删除
- 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) {
- append();
- removeit();
- 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 accept(accepId,fun) {
- var inserted = $("#materialData").datagrid('getChanges', "inserted");
- var deleted = $("#materialData").datagrid('getChanges', "deleted");
- var updated = $("#materialData").datagrid('getChanges', "updated");
- $.ajax({
- type: "post",
- url: "/depotItem/saveDetials",
- data: {
- inserted: JSON.stringify(inserted),
- deleted: JSON.stringify(deleted),
- updated: JSON.stringify(updated),
- headerId:accepId
- },
- success: function (tipInfo)
- {
- if (tipInfo) {
- $.messager.alert('提示','保存成功!','info');
- }
- else {
- $.messager.alert('提示', '保存失败!', 'error');
- }
- fun && fun();
- },
- error: function (XmlHttpRequest, textStatus, errorThrown)
- {
- $.messager.alert('提示',XmlHttpRequest.responseText,'error');
- fun && fun();
- }
- });
- if (endEditing()) {
- $('#materialData').datagrid('acceptChanges');
- }
- }
- //获取MaxId
- function getMaxId(){
- var depotHeadMax=null;
- $.ajax({
- type:"get",
- url: "/depotHead/getMaxId",
- //设置为同步
- async:false,
- dataType: "json",
- success: function (res) {
- if(res && res.code === 200) {
- if(res.data) {
- depotHeadMax = res.data.maxId;
- }
- }
- }
- });
-
- if(depotHeadMax !=null) {
- depotHeadMaxId=depotHeadMax;
- }
- }
-
-
-
-
-
-
+ //初始化界面
+ var kid = sessionStorage.getItem("userId");
+ 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 depotHeadMaxId=null; //获取最大的Id
+ var accepId=null; //保存的主表id
+ var url;
+ var depotHeadID = 0;
+ var preTotalPrice = 0; //前一次加载的金额
+ var orgDepotHead = "";
+ var editIndex = undefined;
+ var listTitle = ""; //单据标题
+ var listType = ""; //入库 出库
+ var listSubType = ""; //采购 销售等
+ var payTypeTitle = "";//付款 收款
+ var organUrl = ""; //组织数据接口地址
+ var amountNum = ""; //单据编号开头字符
+ var depotString = ""; //店铺id列表
+ var orgDefaultId = 0; //单位默认编号
+ 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
+ $(function(){
+ //初始化系统基础信息
+ getType();
+ initSystemData_UB();
+ initSelectInfo_UB();
+ initSystemData_depot();
+ initSelectInfo_depot();
+ initSystemData_person();
+ initSelectInfo_person();
+ initSystemData_account();
+ initSelectInfo_account();
+ initSupplier(); //供应商
+ initSalesman(); //销售人员
+ initGift(); //初始化礼品卡
+ initOutItemList(); //初始化支出项目
+ initMProperty(); //初始化商品属性
+ initTableData();
+ ininPager();
+ initForm();
+ bindEvent();//绑定操作事件
+ });
+ //根据单据名称获取类型
+ function getType(){
+ listTitle = $("#tablePanel").prev().text();
+ depotString = "|";
+ //改变宽度和高度
+ $("#searchPanel").panel({width:webW-2});
+ $("#tablePanel").panel({width:webW-2});
+ var supUrl = "/supplier/findBySelect_sup"; //供应商接口
+ var cusUrl = "/supplier/findBySelect_cus?UBType=UserCustomer&UBKeyId=" + kid; //客户接口
+ var retailUrl = "/supplier/findBySelect_retail"; //散户接口
+ if(listTitle === "采购入库列表"){
+ listType = "入库";
+ listSubType = "采购";
+ payTypeTitle = "付款";
+ organUrl = supUrl;
+ amountNum = "CGRK";
+ }
+ else if(listTitle === "零售退货列表"){
+ listType = "入库";
+ listSubType = "零售退货"; //注:用预付款购买的产品不能退货
+ payTypeTitle = "付款";
+ organUrl = retailUrl;
+ amountNum = "LSTH";
+ }
+ else if(listTitle === "销售退货列表"){
+ listType = "入库";
+ listSubType = "销售退货";
+ payTypeTitle = "付款";
+ organUrl = cusUrl;
+ amountNum = "XSTH";
+ }
+ else if(listTitle === "其它入库列表"){
+ listType = "入库";
+ listSubType = "其它";
+ payTypeTitle = "隐藏";
+ organUrl = supUrl;
+ amountNum = "QTRK";
+ }
+ else if(listTitle === "零售出库列表"){
+ listType = "出库";
+ listSubType = "零售";
+ payTypeTitle = "收款";
+ organUrl = retailUrl;
+ amountNum = "LSCK";
+ }
+ else if(listTitle === "销售出库列表"){
+ listType = "出库";
+ listSubType = "销售";
+ payTypeTitle = "收款";
+ organUrl = cusUrl;
+ amountNum = "XSCK";
+ }
+ else if(listTitle === "采购退货列表"){
+ listType = "出库";
+ listSubType = "采购退货";
+ payTypeTitle = "收款";
+ organUrl = supUrl;
+ amountNum = "CGTH";
+ }
+ else if(listTitle === "其它出库列表"){
+ listType = "出库";
+ listSubType = "其它";
+ payTypeTitle = "隐藏";
+ organUrl = cusUrl;
+ amountNum = "QTCK";
+ }
+ else if(listTitle === "调拨出库列表"){
+ listType = "出库";
+ listSubType = "调拨";
+ payTypeTitle = "隐藏";
+ organUrl = supUrl;
+ amountNum = "DBCK";
+ }
+ else if(listTitle === "礼品充值列表"){
+ listType = "出库";
+ listSubType = "礼品充值";
+ payTypeTitle = "隐藏";
+ organUrl = supUrl;
+ amountNum = "LPCZ";
+ }
+ else if(listTitle === "礼品销售列表"){
+ listType = "出库";
+ listSubType = "礼品销售";
+ payTypeTitle = "隐藏";
+ organUrl = supUrl;
+ amountNum = "LPXS";
+ }
+ else if(listTitle === "组装单列表"){
+ listType = "其它";
+ listSubType = "组装单";
+ payTypeTitle = "隐藏";
+ organUrl = supUrl;
+ amountNum = "ZZD";
+ }
+ else if(listTitle === "拆卸单列表"){
+ listType = "其它";
+ listSubType = "拆卸单";
+ payTypeTitle = "隐藏";
+ organUrl = supUrl;
+ amountNum = "CSD";
+ }
+ }
+ //初始化系统基础信息
+ 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)
+ {
+ 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;
+ }
+ }
+ if(listSubType === "零售"){
+ orgDefaultList = res;
+ }
+ },
+ onSelect: function(rec){
+ if(listSubType === "零售"){
+ var option = "";
+ if(rec.supplier !== "非会员" && rec.advanceIn >0){
+ option = '';
+ option += '';
+ }
+ else {
+ option += '';
+ }
+ $("#payType").empty().append(option);
+ }
+ else{
+ $.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 initGift(){
+ if(listSubType == "礼品充值"|| listSubType == "礼品销售"){
+ $('#GiftId').combobox({
+ url: "/depot/findGiftByType?type=1",
+ valueField:'id',
+ textField:'name'
+ });
+ $('#searchGiftId').combobox({
+ url: "/depot/findGiftByType?type=1",
+ valueField:'id',
+ textField:'name'
+ });
+ }
+ if(listSubType == "礼品销售"){
+ $.ajax({
+ type:"post",
+ url: "/supplier/findBySelectRetailNoPeople.action", //散户接口
+ dataType: "json",
+ success: function (res){
+ if(res && res[0]){
+ orgDefaultId = res[0].id;
+ }
+ }
+ });
+ }
+ }
+
+ //初始化收入项目列表
+ 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(){
+ 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为显示
+ if(listSubType == "调拨" || listSubType == "其它" || listSubType == "零售" || listSubType == "零售退货" || listSubType == "礼品充值" || listSubType == "礼品销售" || listSubType == "组装单" || listSubType == "拆卸单"){
+ isShowLastMoneyColumn = true; //隐藏
+ }
+ var isShowOrganNameColumn = false; //是否显示供应商、客户等信息,true为隐藏,false为显示
+ var organNameTitle = ""; //组织名称标题
+ if(listSubType == "调拨" || listSubType == "礼品充值" || listSubType == "礼品销售" || listSubType == "组装单" || listSubType == "拆卸单"){
+ isShowOrganNameColumn = true; //隐藏
+ }
+ else {
+ if(listTitle == "采购入库列表" || listTitle == "采购退货列表" || listTitle == "其它入库列表"){
+ organNameTitle = "供应商名称";
+ }
+ else if(listTitle == "销售退货列表" || listTitle == "销售出库列表" || listTitle == "其它出库列表"){
+ organNameTitle = "客户名称";
+ }
+ else if(listTitle == "零售出库列表" || listTitle == "零售退货列表"){
+ organNameTitle = "会员卡号";
+ }
+ }
+ $('#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:90,
+ formatter:function(value,rec) {
+ var str = '';
+ var rowInfo = rec.id + 'AaBb' + rec.projectid+ 'AaBb' + rec.number+ 'AaBb' + rec.operpersonname
+ + 'AaBb' + rec.opertime+ 'AaBb' + rec.organid+ 'AaBb' + rec.handspersonid
+ + 'AaBb' + rec.accountid+ 'AaBb' + rec.changeamount+ 'AaBb' + rec.remark
+ + 'AaBb' + rec.projectName+ 'AaBb' + rec.organName+ 'AaBb' + rec.handsPersonName
+ + 'AaBb' + rec.accountName + 'AaBb' + rec.totalprice + 'AaBb' + rec.allocationprojectid
+ + 'AaBb' + rec.allocationProjectName + 'AaBb' + rec.paytype + 'AaBb' + rec.salesman
+ + 'AaBb' + rec.discount + 'AaBb' + rec.discountmoney + 'AaBb' + rec.discountlastmoney
+ + 'AaBb' + rec.accountidlist + 'AaBb' + rec.accountmoneylist
+ + 'AaBb' + rec.othermoney + 'AaBb' + rec.othermoneylist + 'AaBb' + rec.othermoneyitem + 'AaBb' + rec.accountday;
+ rowInfo = rowInfo.replace(/\"/g, "");
+ rowInfo = rowInfo.replace(/\[|]/g,"");
+ var orgId = rec.organid? rec.organid:0;
+ str += '
';
+ str += '
';
+ str += '
';
+ return str;
+ }
+ },
+ { title: organNameTitle, field: 'organName',width:120, hidden:isShowOrganNameColumn},
+ { title: '单据编号',field: 'number',width:130},
+ { title: '商品信息',field: 'materialsList',width:180,formatter:function(value){
+ if(value) {
+ return value.replace(",",",");
+ }
+ }
+ },
+ { title: '单据日期 ',field: 'opertime',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){
+ return value? "已审核":"未审核";
+ }
+ }
+ ]],
+ 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("("));
+ }
+ var unitArr = unitName.split(",");
+ var basicUnit = unitArr[0]; //基础单位
+ var otherUnit = unitArr[1]; //副单位
+ var unitSetInput =""; //单位
+ if(listSubType === "采购" || listSubType === "采购退货"){
+ unitSetInput = rec.data[0].firstinunit;
+ if(basicUnit==unitSetInput){ //基础单位等于选择的单位
+ loadRatio = 1;
+ }
+ else if(otherUnit==unitSetInput){ //副单位等于选择的单位
+ loadRatio = thisRatio;
+ }
+ }
+ else if(listSubType === "销售" || listSubType === "销售退货" || listTitle == "礼品充值" || listTitle == "礼品销售" || listSubType === "零售" || listSubType === "零售退货"){
+ 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,
+ monthTime: monthTime,
+ currentPage: 1,
+ pageSize: 10
+ },
+ 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.rows[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)); //本次欠款
+
+ if(listSubType == "零售" || listSubType == "零售退货") {
+ $("#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 = "";
+ if(listSubType == "调拨"){
+ isShowAnotherDepot = false; //调拨时候显示对方仓库
+ anotherDepotHeadName = "调入仓库";
+ anotherDepotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
+ anotherDepotTextField = "depotName";
+ }
+ if(listSubType == "礼品充值"){
+ isShowAnotherDepot = false; //礼品充值时候显示礼品卡
+ anotherDepotHeadName = "礼品卡";
+ anotherDepotUrl = "/depot/findGiftByType.action?type=1";
+ anotherDepotTextField = "name";
+ }
+ if(listSubType == "礼品销售"){
+ depotHeadName = "礼品卡";
+ depotUrl = "/depot/findGiftByType.action?type=1";
+ depotTextField = "name";
+ }
+ else {
+ depotHeadName = "仓库名称";
+ depotUrl = '/depot/findDepotByUserId?UBType=UserDepot&UBKeyId='+kid;
+ depotTextField = "depotName";
+ }
+ var isShowTaxColumn = false; //是否显示税率相关的列,true为隐藏,false为显示
+ if(listSubType == "调拨" || listSubType == "其它" || listSubType == "零售" || listSubType == "零售退货" || listSubType == "礼品充值" || listSubType == "礼品销售" || listSubType == "组装单" || listSubType == "拆卸单"){
+ isShowTaxColumn = true; //隐藏
+ }
+ var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
+ if(listSubType == "组装单" || listSubType == "拆卸单"){
+ isShowMaterialTypeColumn = 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;
+ if(unitName) {
+ ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值
+ unitName = unitName.substring(0, unitName.indexOf("("));
+ }
+ var unitArr = unitName.split(",");
+ var basicUnit = unitArr[0]; //基础单位
+ var otherUnit = unitArr[1]; //副单位
+ var unitSetInput =""; //单位
+ body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读
+ var loadRatio = 1; //在单位输入框上面加载比例字段
+ if(listSubType === "采购" || listSubType === "采购退货"){
+ unitSetInput = res.data[0].firstinunit; //给单位文本框赋值
+ if(basicUnit==unitSetInput){ //基础单位等于选择的单位
+ loadRatio = 1;
+ }
+ else if(otherUnit==unitSetInput){ //副单位等于选择的单位
+ loadRatio = ratio;
+ }
+ }
+ else if(listSubType === "销售" || listSubType === "销售退货" || listSubType === "礼品充值" || listSubType === "礼品销售" || listSubType === "零售" || listSubType === "零售退货"){
+ 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"){
+ if(listTitle == "采购入库列表" || listTitle == "销售退货列表" || listTitle == "其它入库列表") {
+ UnitPrice = basicPresetPriceOne;
+ }
+ else if(listTitle == "销售出库列表" || listTitle == "采购退货列表" || listTitle == "其它出库列表" || listTitle == "调拨出库列表" || listTitle == "礼品充值列表" || listTitle == "礼品销售列表") {
+ UnitPrice = basicPresetPriceTwo;
+ }
+ else if(listTitle == "零售出库列表" || listTitle == "零售退货列表"){
+ UnitPrice = retailPriceOne;
+ }
+ body.find("[field='Stock']").find(input).val(stock); //修改库存
+ }
+ else if(type === "other"){
+ if(listTitle == "采购入库列表" || listTitle == "销售退货列表" || listTitle == "其它入库列表") {
+ UnitPrice = otherPresetPriceOne;
+ }
+ else if(listTitle == "销售出库列表" || listTitle == "采购退货列表" || listTitle == "其它出库列表" || listTitle == "调拨出库列表" || listTitle == "礼品充值列表" || listTitle == "礼品销售列表") {
+ UnitPrice = otherPresetPriceTwo;
+ }
+ else if(listTitle == "零售出库列表" || listTitle == "零售退货列表"){
+ 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(listSubType == "零售" || listSubType == "零售退货") {
+ if(res.data[0].unit) { //如果存在计量单位信息
+ detailPrice = retailPrice;
+ }
+ else {
+ if (firstOutUnit == basicUnit) {
+ detailPrice = retailPriceOne;
+ }
+ else if (firstOutUnit == otherUnit) {
+ detailPrice = retailPriceTwo;
+ }
+ }
+ }
+ else if(listTitle == "采购入库列表" || listTitle == "销售退货列表" || listTitle == "其它入库列表") {
+ if(res.data[0].unit) { //如果存在计量单位信息
+ detailPrice = presetPriceOne;
+ }
+ else {
+ if (firstInUnit == basicUnit) {
+ detailPrice = basicPresetPriceOne;
+ }
+ else if (firstInUnit == otherUnit) {
+ detailPrice = otherPresetPriceOne;
+ }
+ }
+ }
+ else if(listTitle == "销售出库列表" || listTitle == "采购退货列表" || listTitle == "其它出库列表" || listTitle == "调拨出库列表" || listTitle == "礼品充值列表" || listTitle == "礼品销售列表") {
+ 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()
+ {
+ removeit(); //删除
+ }
+ },
+ {
+ 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);
+ }
+ },
+ error:function() {
+ $.messager.alert('查询提示','查询数据后台异常,请稍后再试!','error');
+ }
+ });
+ }
+
+ //初始化表格数据-商品列表-查看状态
+ function initTableData_material_show(TotalPrice){
+ var isShowAnotherDepot = true; //显示对方仓库,true为隐藏,false为显示
+ var anotherDepotHeadName = ""; //对方仓库的列的标题
+ var depotHeadName = ""; //仓库的列的标题
+ if(listSubType == "调拨"){
+ isShowAnotherDepot = false; //调拨时候显示对方仓库
+ anotherDepotHeadName = "调入仓库";
+ }
+ if(listSubType == "礼品充值"){
+ isShowAnotherDepot = false; //礼品充值时候显示礼品卡
+ anotherDepotHeadName = "礼品卡";
+ }
+ if(listSubType == "礼品销售"){
+ depotHeadName = "礼品卡";
+ }
+ else {
+ depotHeadName = "仓库名称";
+ }
+ var isShowTaxColumn = false; //是否显示税率相关的列,true为隐藏,false为显示
+ if(listSubType == "调拨" || listSubType == "其它" || listSubType == "零售" || listSubType == "零售退货" || listSubType == "礼品充值" || listSubType == "礼品销售" || listSubType == "组装单" || listSubType == "拆卸单"){
+ isShowTaxColumn = true; //隐藏
+ }
+ var isShowMaterialTypeColumn = true; //是否显示商品类型相关的列,true为隐藏,false为显示
+ if(listSubType == "组装单" || listSubType == "拆卸单"){
+ isShowMaterialTypeColumn = 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) {
+ $.messager.alert('删除提示','已审核的单据不能删除!','warning');
+ return;
+ }
+ $.messager.confirm('删除确认','确定要删除此单据信息吗?',function(r) {
+ if (r) {
+ $.ajax({
+ type:"post",
+ url: "/depotHead/" + depotHeadID + "/delete",
+ dataType: "json",
+ 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 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;
+ }
+ //alert(row[i].id);
+ ids += row[i].id + ",";
+ }
+ //批量更新会员的预收款信息
+ for(var i = 0;i < row.length; i ++) {
+ if(listSubType === "零售") {
+ $.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",
+ 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;
+ }
+ });
+ }
+ });
+ }
+ }
+
+ //批量审核
+ 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)
+ {
+ ids += row[i].id;
+ break;
+ }
+ ids += row[i].id + ",";
+ }
+ $.ajax({
+ type:"post",
+ url: "/depotHead/batchSetStatus",
+ dataType: "json",
+ async : false,
+ data: ({
+ status: true,
+ 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;
+ }
+ });
+ }
+ });
+ }
+ }
+
+ //批量反审核
+ 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)
+ {
+ ids += row[i].id;
+ break;
+ }
+ ids += row[i].id + ",";
+ }
+ $.ajax({
+ type:"post",
+ url: "/depotHead/batchSetStatus",
+ dataType: "json",
+ async : false,
+ data: ({
+ status: false,
+ 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;
+ }
+ });
+ }
+ });
+ }
+ }
+
+ //新增信息
+ function addDepotHead(){
+ $("#clientIp").val(clientIp);
+ $('#depotHeadFM').form('clear');
+ var thisDateTime = getNowFormatDateTime(); //当前时间
+ $("#OperTime").val(thisDateTime);
+ var thisNumber = getNowFormatDateNum(); //根据时间生成编号
+ var thisDate = getNowFormatDate(); //当前日期
+ var beginTime = thisDate + " 00:00:00";
+ var endTime = thisDate + " 23:59:59";
+ //生成单据编号
+ $.ajax({
+ type: "get",
+ url: "/depotHead/buildNumber",
+ data: {
+ type: listType,
+ subType: listSubType,
+ beginTime: beginTime,
+ endTime: endTime
+ },
+ success:function(res){
+ if(res && res.code === 200){
+ var obj = res.data;
+ var defaultNumber = obj.DefaultNumber;
+ var thisDateTwo = getNowFormatDateTwo(); //当前日期
+ var newNumber = amountNum + thisDateTwo + defaultNumber
+ $("#Number").val(newNumber).attr("data-defaultNumber",newNumber);
+ }
+ },
+ error:function(){
+ $.messager.alert('提示','生成单据编号失败!','error');
+ }
+ });
+ //初始化优惠率、优惠金额、优惠后金额、本次付|收款、本次欠款 为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','
增加供应商信息');
+ });
+ url = '/depotHead/add';
+
+ //零售单据修改收款时,自动计算找零
+ if(listSubType == "零售" || listSubType == "零售退货") {
+ $("#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(depotHeadTotalInfo, status){
+ if(status) {
+ $.messager.alert('编辑提示','已审核的单据不能编辑!','warning');
+ return;
+ }
+ var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
+ $("#clientIp").val(clientIp);
+ if(listSubType==="礼品销售"){
+ $("#GiftId").combobox('setValue',depotHeadInfo[1]);
+ }
+ else{
+ $("#ProjectId").focus().val(depotHeadInfo[1]);
+ }
+ var ProjectId=depotHeadInfo[1];
+ if(ProjectId!='')
+ {
+ initSystemData_person(ProjectId);
+ initSelectInfo_person();
+ }
+ $("#Number").val(depotHeadInfo[2]).attr("data-defaultNumber",depotHeadInfo[2]);
+ $("#OperTime").val(depotHeadInfo[4]);
+ $('#OrganId').combobox('setValue', depotHeadInfo[5]);
+ $("#HandsPersonId").val(depotHeadInfo[6]);
+ $("#AccountId").val(depotHeadInfo[7]);
+ $("#ChangeAmount").val(depotHeadInfo[8]);
+ $("#ChangeAmount").attr("data-changeamount", depotHeadInfo[8]);
+ $("#Remark").val(depotHeadInfo[9]);
+ $("#Discount").val(depotHeadInfo[19]);
+ $("#DiscountMoney").val(depotHeadInfo[20]);
+ $("#DiscountLastMoney").val(depotHeadInfo[21]);
+ $("#Debt").val((depotHeadInfo[21]-depotHeadInfo[8]).toFixed(2));
+ $("#AccountDay").val(depotHeadInfo[27].replace("undefined","")); //结算天数
+ var TotalPrice = depotHeadInfo[14];
+ preTotalPrice = depotHeadInfo[14]; //记录前一次合计金额,用于扣预付款
+ $("#AllocationProjectId").val(depotHeadInfo[15]);
+ if(listSubType==="礼品充值"){
+ $("#GiftId").combobox('setValue', depotHeadInfo[15]);
+ }
+ oldNumber = depotHeadInfo[2]; //记录编辑前的单据编号
+ oldId = depotHeadInfo[0]; //记录单据Id
+ var editTitle = listTitle.replace("列表","信息");
+ $('#depotHeadDlg').dialog('open').dialog('setTitle','
编辑' + editTitle);
+ $(".window-mask").css({ width: webW ,height: webH});
+ depotHeadID = depotHeadInfo[0];
+
+ if(listSubType == "零售"){
+ var option = "";
+ if(depotHeadInfo[17] === "预付款"){
+ option = '';
+ option += '';
+ }
+ else {
+ option += '';
+ }
+ $("#payType").empty().append(option);
+ }
+
+ if(listSubType === "销售" || listSubType === "销售退货"){
+ if(depotHeadInfo[18]){
+ var arr = depotHeadInfo[18].split(",");
+ var salesmanArray = [];
+ for(var i=0;i",""));
+ }
+ }
+ $("#Salesman").combobox('setValues', salesmanArray);
+ }
+ }
+
+ //采购入库、销售出库的多账户加载
+ if(depotHeadInfo[22]!="undefined" && depotHeadInfo[23]!="undefined"){
+ $("#AccountId").val("many"); //下拉框选中多账户
+ var accountArr = depotHeadInfo[22].split(",");
+ var accountMoneyArr = depotHeadInfo[23].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(depotHeadInfo[25] && depotHeadInfo[26]){
+ $("#OtherMoney").val(depotHeadInfo[24].replace("undefined","0")); //采购费用、销售费用
+ var itemArr = depotHeadInfo[25].split(",");
+ var itemMoneyArr = depotHeadInfo[26].split(",");
+ $("#OtherMoney").attr("data-itemArr",JSON.stringify(itemArr)).attr("data-itemMoneyArr",JSON.stringify(itemMoneyArr)); //json数据存储
+ }
+
+ initTableData_material("edit",TotalPrice); //商品列表
+ reject(); //撤销下、刷新商品列表
+ url = '/depotHead/update?id=' + depotHeadInfo[0];
+ }
+
+ //查看信息
+ function showDepotHead(depotHeadTotalInfo){
+ var depotHeadInfo = depotHeadTotalInfo.split("AaBb");
+ var manyAccountMoney = 0; //多账户合计-零售
+ $("#ProjectIdShow").text(depotHeadInfo[10]);
+ $("#NumberShow").text(depotHeadInfo[2]);
+ $("#OperTimeShow").text(depotHeadInfo[4]);
+ $('#OrganIdShow').text(depotHeadInfo[11]);
+ $("#HandsPersonIdShow").text(depotHeadInfo[12]);
+ if(depotHeadInfo[13] && depotHeadInfo[13]!="undefined"){
+ $("#AccountIdShow").text(depotHeadInfo[13]); //结算账户
+ } else {
+ var accountArr = depotHeadInfo[22].split(","); //账户id列表
+ var accountMoneyArr = depotHeadInfo[23].split(","); //账户金额列表
+ var accountIdShow = "";
+ for(var j =0;j 查看' + showTitle);
+ $(".window-mask").css({ width: webW ,height: webH});
+
+ depotHeadID = depotHeadInfo[0];
+ initTableData_material_show(TotalPrice); //商品列表-查看状态
+
+ //零售单据展示数据
+ if(listSubType == "零售" || listSubType == "零售退货"){
+ 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);
+ }
+ }
+ if(listSubType === "销售" || listSubType === "销售退货"){
+ if(depotHeadInfo[18]){
+ var arr = depotHeadInfo[18].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;
+ }
+ //保存信息
+ $("#saveDepotHead").off("click").on("click",function(){
+ if(!$('#depotHeadFM').form('validate')){
+ return;
+ }
+ else {
+ //如果初始编号被修改了,就要判断单据编号是否存在
+ if($.trim($("#Number").val()) != $('#Number').attr("data-defaultNumber")){
+ //调用查询单据编号是否重名的方法
+ if(checkDepotHeadNumber()){
+ return;
+ }
+ }
+ //输入框提示
+ if(listTitle === "采购入库列表"){
+ if(!$('#OrganId').combobox('getValue')){
+ $.messager.alert('提示','请选择供应商!','warning');
+ return;
+ }
+ if(!$('#AccountId').val()){
+ $.messager.alert('提示','请选择结算账户!','warning');
+ return;
+ }
+ }
+ else if(listTitle === "零售退货列表"){
+ if(!$('#AccountId').val()){
+ $.messager.alert('提示','请选择付款账户!','warning');
+ return;
+ }
+ if($("#AccountId").val() == "many" && $("#backAmount").val()-0 >0) {
+ $.messager.alert('提示', '选择多账户时的找零金额不能大于0!', 'warning');
+ return;
+ }
+ }
+ else if(listTitle === "销售退货列表"){
+ if(!$('#OrganId').combobox('getValue')){
+ $.messager.alert('提示','请选择退货单位!','warning');
+ return;
+ }
+ if(!$('#AccountId').val()){
+ $.messager.alert('提示','请选择付款账户!','warning');
+ return;
+ }
+ }
+ else if(listTitle === "其它入库列表"){
+ if(!$('#OrganId').combobox('getValue')){
+ $.messager.alert('提示','请选择往来单位!','warning');
+ return;
+ }
+ }
+ else if(listTitle === "零售出库列表"){
+ 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;
+ }
+ }
+ else if(listTitle === "销售出库列表"){
+ if(!$('#OrganId').combobox('getValue')){
+ $.messager.alert('提示','请选择购买单位!','warning');
+ return;
+ }
+ if(!$('#AccountId').val()){
+ $.messager.alert('提示','请选择收款账户!','warning');
+ return;
+ }
+ }
+ else if(listTitle === "采购退货列表"){
+ if(!$('#OrganId').combobox('getValue')){
+ $.messager.alert('提示','请选择收货单位!','warning');
+ return;
+ }
+ if(!$('#AccountId').val()){
+ $.messager.alert('提示','请选择收款账户!','warning');
+ return;
+ }
+ }
+ else if(listTitle === "其它出库列表"){
+ if(!$('#OrganId').combobox('getValue')){
+ $.messager.alert('提示','请选择往来单位!','warning');
+ return;
+ }
+ }
+ else if(listTitle === "调拨出库列表"){
+
+ }
+ //进行明细的校验
+ 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(","); //转为数组
+ }
+ if(listSubType === "采购"||listSubType === "零售退货"||listSubType === "销售退货"){
+ //付款为负数
+ ChangeAmount = 0 - ChangeAmount;
+ TotalPrice = 0 - TotalPrice;
+ if(accountMoneyArr) {
+ accountMoneyArr = changeListFmtMinus(accountMoneyArr); //将数组单个金额中的数值转为负数
+ }
+ }
+ //零售时候,可以从会员预付款中扣款
+ var thisPayType = "现付";
+ if(listSubType === "零售") {
+ if($("#payType").val() ==="预付款") {
+ thisPayType = "预付款";
+ }
+ }
+ var SalesmanStr = "";
+ if(listSubType === "销售" || listSubType === "销售退货"){
+ 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;
+ }
+ $.ajax({
+ type:"post",
+ url: url,
+ dataType: "json",
+ async : false,
+ data: ({
+ info : JSON.stringify({
+ Type: listType,
+ SubType: listSubType,
+ ProjectId: ProjectId,
+ AllocationProjectId: AllocationProjectId,
+ DefaultNumber: $.trim($("#Number").attr("data-defaultNumber")),//初始编号
+ Number: $.trim($("#Number").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() //结算天数
+ })
+ }),
+ success: function (tipInfo)
+ {
+ if(tipInfo)
+ {
+ function closeDialog(){
+ $('#depotHeadDlg').dialog('close');
+ var opts = $("#tableData").datagrid('options');
+ showDepotHeadDetails(opts.pageNumber,opts.pageSize);
+ }
+
+ if(thisPayType === "预付款") {
+ //更新用户信息-预付款
+ var advanceIn = 0; //预付款金额
+ if(depotHeadID){
+ advanceIn = TotalPrice - preTotalPrice; //修改时,预付款=合计金额-加载金额
+ }
+ else{
+ advanceIn = TotalPrice; //新增时,预付款=合计金额
+ }
+ $.ajax({
+ type:"post",
+ url: "/supplier/updateAdvanceIn",
+ dataType: "json",
+ data:{
+ supplierId: OrganId, //会员id
+ advanceIn: 0 - advanceIn //保存的同时扣掉用户的预付款
+ },
+ success: function(res){
+ if(res && res.code === 200) {
+ //保存会员预收款成功
+ }
+ },
+ error: function(){
+ $.messager.alert('提示','保存信息异常,请稍后再试!','error');
+ return;
+ }
+ });
+ }
+
+ //保存明细记录
+ if(depotHeadID ==0)
+ {
+ getMaxId(); //查找最大的Id
+ accept(depotHeadMaxId,closeDialog); //新增
+ }
+ else
+ {
+ accept(depotHeadID,closeDialog); //修改
+ }
+ }
+ else
+ {
+ $.messager.show({
+ title: '错误提示',
+ msg: '保存信息失败,请稍后重试!'
+ });
+ }
+ },
+ //此处添加错误处理
+ error:function()
+ {
+ $.messager.alert('提示','保存信息异常,请稍后再试!','error');
+ return;
+ }
+ });
+ }
+ });
+
+ //初始化键盘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数据存储
+ }
+ if(listSubType==="零售" || listSubType==="零售退货") {
+ $("#getAmount").val(accountMoneyTotal); //给付款或者收款金额赋值
+ var backAmount = $("#getAmount").val() - $("#ChangeAmount").val();
+ $("#backAmount").val((backAmount - 0).toFixed(2)); //计算找零金额
+ }
+ else {
+ $("#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"); //将下拉置空并把缓存参数清空
+ if(listSubType==="零售" || listSubType==="零售退货"){
+ $("#ChangeAmount").prop("readonly","readonly");
+ }
+ else {
+ $("#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"); //将下拉置空并把缓存参数清空
+ if(listSubType==="零售" || listSubType==="零售退货"){
+ $("#ChangeAmount").prop("readonly","readonly");
+ }
+ else {
+ $("#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]);
+ });
+ if(listSubType==="零售" || listSubType==="零售退货") {
+ $("#accountMoneyTotalDlg").text($("#getAmount").val());
+ }
+ else {
+ $("#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());
+ });
+
+ if(listTitle === "采购入库列表"){
+ //检查单位名称是否存在 ++ 重名无法提示问题需要跟进
+ 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(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 = "供应商";
+ 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());
+ $.ajax({
+ type:"get",
+ url: "/depotItem/getHeaderIdByMaterial",
+ dataType: "json",
+ data: ({
+ materialParam: materialParam,
+ depotIds: depotString
+ }),
+ success: function (res) {
+ if(res && res.code === 200) {
+ var ids = res.data;
+ if(ids){
+ $.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: $("#searchBeginTime").val(),
+ endTime: $("#searchEndTime").val(),
+ dhIds: ids
+ }),
+ 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;
+ }
+ });
+ }
+ else {
+ $("#tableData").datagrid('loadData', []);
+ }
+ }
+ },
+ //此处添加错误处理
+ 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 = "普通子件";
+ }
+ if(listSubType == "组装单" || listSubType == "拆卸单"){
+ 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', {});
+ editIndex = $('#materialData').datagrid('getRows').length - 1;
+ $('#materialData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
+ autoReckon();
+ }
+ }
+ //删除
+ 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) {
+ append();
+ removeit();
+ 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 accept(accepId,fun) {
+ var inserted = $("#materialData").datagrid('getChanges', "inserted");
+ var deleted = $("#materialData").datagrid('getChanges', "deleted");
+ var updated = $("#materialData").datagrid('getChanges', "updated");
+ $.ajax({
+ type: "post",
+ url: "/depotItem/saveDetials",
+ data: {
+ inserted: JSON.stringify(inserted),
+ deleted: JSON.stringify(deleted),
+ updated: JSON.stringify(updated),
+ headerId:accepId
+ },
+ success: function (tipInfo)
+ {
+ if (tipInfo) {
+ $.messager.alert('提示','保存成功!','info');
+ }
+ else {
+ $.messager.alert('提示', '保存失败!', 'error');
+ }
+ fun && fun();
+ },
+ error: function (XmlHttpRequest, textStatus, errorThrown)
+ {
+ $.messager.alert('提示',XmlHttpRequest.responseText,'error');
+ fun && fun();
+ }
+ });
+ if (endEditing()) {
+ $('#materialData').datagrid('acceptChanges');
+ }
+ }
+ //获取MaxId
+ function getMaxId(){
+ var depotHeadMax=null;
+ $.ajax({
+ type:"get",
+ url: "/depotHead/getMaxId",
+ //设置为同步
+ async:false,
+ dataType: "json",
+ success: function (res) {
+ if(res && res.code === 200) {
+ if(res.data) {
+ depotHeadMax = res.data.maxId;
+ }
+ }
+ }
+ });
+
+ if(depotHeadMax !=null) {
+ depotHeadMaxId=depotHeadMax;
+ }
+ }
+
+
+
+
+
+
diff --git a/erp_web/js/print/print.js b/erp_web/js/print/print.js
index f52f822a..e2bb9064 100644
--- a/erp_web/js/print/print.js
+++ b/erp_web/js/print/print.js
@@ -1,112 +1,118 @@
-// strPrintName 打印任务名
-// printDatagrid 要打印的datagrid
-function CreateFormPage(strPrintName, printDatagrid, path) {
- var beginDate= $("#searchBeginTime").val();
- var endDate= $("#searchEndTime").val();
- var getMonth= $("#searchMonth").val();
- var listTitle = $("#tablePanel").prev().text();
- listTitle = listTitle.replace("列表","");
- var companyName = "";
- //加载公司信息
- $.ajax({
- type:"get",
- url: path + "/systemConfig/findBy.action",
- dataType: "json",
- async: false,
- success: function (res) {
- if(res && res.rows) {
- var array = res.rows;
- for(var i=0; i';
- if(beginDate && endDate) {
- tableString+='\n日期:' + beginDate + ' 至 ' + endDate + ' \n
';
- }
- if(getMonth) {
- tableString += '\n月份:' + getMonth + ' \n
';
- }
- tableString+='\n';
- var frozenColumns = printDatagrid.datagrid("options").frozenColumns; // 得到frozenColumns对象
- var columns = printDatagrid.datagrid("options").columns; // 得到columns对象
- var nameList = '';
-
- // 载入title
- if (typeof columns != 'undefined' && columns != '') {
- $(columns).each(function (index) {
- tableString += '\n';
- if (typeof frozenColumns != 'undefined' && typeof frozenColumns[index] != 'undefined') {
- for (var i = 0; i < frozenColumns[index].length; ++i) {
- if (!frozenColumns[index][i].hidden) {
- tableString += '\n| 1) {
- tableString += ' rowspan="' + frozenColumns[index][i].rowspan + '"';
- }
- if (typeof frozenColumns[index][i].colspan != 'undefined' && frozenColumns[index][i].colspan > 1) {
- tableString += ' colspan="' + frozenColumns[index][i].colspan + '"';
- }
- if (typeof frozenColumns[index][i].field != 'undefined' && frozenColumns[index][i].field != '') {
- nameList += ',{"f":"' + frozenColumns[index][i].field + '", "a":"' + frozenColumns[index][i].align + '"}';
- }
- tableString += '>' + frozenColumns[0][i].title + ' | ';
- }
- }
- }
- for (var i = 0; i < columns[index].length; ++i) {
- if (!columns[index][i].hidden) {
- tableString += '\n 1) {
- tableString += ' rowspan="' + columns[index][i].rowspan + '"';
- }
- if (typeof columns[index][i].colspan != 'undefined' && columns[index][i].colspan > 1) {
- tableString += ' colspan="' + columns[index][i].colspan + '"';
- }
- if (typeof columns[index][i].field != 'undefined' && columns[index][i].field != '') {
- nameList += ',{"f":"' + columns[index][i].field + '", "a":"' + columns[index][i].align + '"}';
- }
- tableString += '>' + columns[index][i].title + ' | ';
- }
- }
- tableString += '\n
';
- });
- }
- // 载入内容
- var rows = printDatagrid.datagrid("getRows"); // 这段代码是获取当前页的所有行
- var nl = eval('([' + nameList.substring(1) + '])');
- for (var i = 0; i < rows.length; ++i) {
- tableString += '\n';
- $(nl).each(function (j) {
- var e = nl[j].f.lastIndexOf('_0');
-
- tableString += '\n| ';
- if (e + 2 == nl[j].f.length) {
- tableString += rows[i][nl[j].f.substring(0, e)];
- }
- else
- tableString += rows[i][nl[j].f];
- tableString += ' | ';
- });
- tableString += '\n
';
- }
- tableString += '\n
';
-
- localStorage.setItem("tableString",tableString);
-
- window.open("../../js/print/print.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
+// strPrintName 打印任务名
+// printDatagrid 要打印的datagrid
+function CreateFormPage(strPrintName, printDatagrid) {
+ var beginDate= $("#searchBeginTime").val();
+ var endDate= $("#searchEndTime").val();
+ var getMonth= $("#searchMonth").val();
+ var listTitle = $("#tablePanel").prev().text();
+ listTitle = listTitle.replace("列表","");
+ var companyName = "";
+ //加载公司信息
+ $.ajax({
+ type:"get",
+ url: "/systemConfig/list",
+ dataType: "json",
+ data: ({
+ currentPage: 1,
+ pageSize: 100
+ }),
+ async: false,
+ success: function (res) {
+ if (res && res.code === 200) {
+ if(res.data && res.data.page) {
+ var array = res.data.page.rows;
+ for (var i = 0; i < array.length; i++) {
+ var name = array[i].name;
+ if (name === "company_name") {
+ companyName = array[i].value;
+ }
+ }
+ }
+ }
+ },
+ //此处添加错误处理
+ error:function() {
+ $.messager.alert('查询失败','查询系统配置信息异常,请稍后再试!','error');
+ return;
+ }
+ });
+
+ var tableString = '' + companyName + "-" + listTitle + '\n
';
+ if(beginDate && endDate) {
+ tableString+='\n日期:' + beginDate + ' 至 ' + endDate + ' \n
';
+ }
+ if(getMonth) {
+ tableString += '\n月份:' + getMonth + ' \n
';
+ }
+ tableString+='\n';
+ var frozenColumns = printDatagrid.datagrid("options").frozenColumns; // 得到frozenColumns对象
+ var columns = printDatagrid.datagrid("options").columns; // 得到columns对象
+ var nameList = '';
+
+ // 载入title
+ if (typeof columns != 'undefined' && columns != '') {
+ $(columns).each(function (index) {
+ tableString += '\n';
+ if (typeof frozenColumns != 'undefined' && typeof frozenColumns[index] != 'undefined') {
+ for (var i = 0; i < frozenColumns[index].length; ++i) {
+ if (!frozenColumns[index][i].hidden) {
+ tableString += '\n| 1) {
+ tableString += ' rowspan="' + frozenColumns[index][i].rowspan + '"';
+ }
+ if (typeof frozenColumns[index][i].colspan != 'undefined' && frozenColumns[index][i].colspan > 1) {
+ tableString += ' colspan="' + frozenColumns[index][i].colspan + '"';
+ }
+ if (typeof frozenColumns[index][i].field != 'undefined' && frozenColumns[index][i].field != '') {
+ nameList += ',{"f":"' + frozenColumns[index][i].field + '", "a":"' + frozenColumns[index][i].align + '"}';
+ }
+ tableString += '>' + frozenColumns[0][i].title + ' | ';
+ }
+ }
+ }
+ for (var i = 0; i < columns[index].length; ++i) {
+ if (!columns[index][i].hidden) {
+ tableString += '\n 1) {
+ tableString += ' rowspan="' + columns[index][i].rowspan + '"';
+ }
+ if (typeof columns[index][i].colspan != 'undefined' && columns[index][i].colspan > 1) {
+ tableString += ' colspan="' + columns[index][i].colspan + '"';
+ }
+ if (typeof columns[index][i].field != 'undefined' && columns[index][i].field != '') {
+ nameList += ',{"f":"' + columns[index][i].field + '", "a":"' + columns[index][i].align + '"}';
+ }
+ tableString += '>' + columns[index][i].title + ' | ';
+ }
+ }
+ tableString += '\n
';
+ });
+ }
+ // 载入内容
+ var rows = printDatagrid.datagrid("getRows"); // 这段代码是获取当前页的所有行
+ var nl = eval('([' + nameList.substring(1) + '])');
+ for (var i = 0; i < rows.length; ++i) {
+ tableString += '\n';
+ $(nl).each(function (j) {
+ var e = nl[j].f.lastIndexOf('_0');
+
+ tableString += '\n| ';
+ if (e + 2 == nl[j].f.length) {
+ tableString += rows[i][nl[j].f.substring(0, e)];
+ }
+ else
+ tableString += rows[i][nl[j].f];
+ tableString += ' | ';
+ });
+ tableString += '\n
';
+ }
+ tableString += '\n
';
+
+ localStorage.setItem("tableString",tableString);
+
+ window.open("../../js/print/print.html","location:No;status:No;help:No;dialogWidth:800px;dialogHeight:600px;scroll:auto;");
}
\ No newline at end of file
diff --git a/erp_web/pages/manage/app.html b/erp_web/pages/manage/app.html
index 591755e7..4d8f47af 100644
--- a/erp_web/pages/manage/app.html
+++ b/erp_web/pages/manage/app.html
@@ -1,520 +1,527 @@
-
-
-
- 应用管理
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 应用管理
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erp_web/pages/manage/customer.html b/erp_web/pages/manage/customer.html
index 80635dda..346d774f 100644
--- a/erp_web/pages/manage/customer.html
+++ b/erp_web/pages/manage/customer.html
@@ -1,187 +1,186 @@
-
-
-
- 客户信息
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 客户信息
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erp_web/pages/manage/functions.html b/erp_web/pages/manage/functions.html
index 70ce2252..e073f307 100644
--- a/erp_web/pages/manage/functions.html
+++ b/erp_web/pages/manage/functions.html
@@ -1,509 +1,516 @@
-
-
-
- 功能管理
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 功能管理
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erp_web/pages/manage/member.html b/erp_web/pages/manage/member.html
index e8edb527..b6680d80 100644
--- a/erp_web/pages/manage/member.html
+++ b/erp_web/pages/manage/member.html
@@ -1,187 +1,186 @@
-
-
-
- 会员信息
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 会员信息
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erp_web/pages/manage/vendor.html b/erp_web/pages/manage/vendor.html
index bea921ff..31fe9735 100644
--- a/erp_web/pages/manage/vendor.html
+++ b/erp_web/pages/manage/vendor.html
@@ -1,188 +1,187 @@
-
-
-
- 供应商信息
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 供应商信息
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erp_web/pages/materials/material.html b/erp_web/pages/materials/material.html
index 9f78ccfb..b211997d 100644
--- a/erp_web/pages/materials/material.html
+++ b/erp_web/pages/materials/material.html
@@ -1,1629 +1,1636 @@
-
-
-
- 商品信息
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 商品信息
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/erp_web/pages/materials/purchase_in_list.html b/erp_web/pages/materials/purchase_in_list.html
index 231f2122..4e42fd31 100644
--- a/erp_web/pages/materials/purchase_in_list.html
+++ b/erp_web/pages/materials/purchase_in_list.html
@@ -1,382 +1,382 @@
-
-
-
- 采购入库
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- | 供应商: |
-
-
- |
- 单据日期: |
-
-
- |
- 单据编号: |
-
-
- |
- |
- |
- |
-
-
- |
-
-
- |
-
-
- | 单据备注: |
-
-
- |
-
-
- | 优惠率: |
-
-
- %
- |
- 付款优惠: |
-
-
- |
- 优惠后金额: |
-
-
- |
- 本次付款: |
-
-
- |
- |
-
-
- | 结算账户: |
-
-
- |
- 本次欠款: |
-
-
- |
- 采购费用: |
-
-
- |
- 结算天数: |
-
-
- |
- |
-
-
-
-
-
-
- |
- 结算账户 |
- 金额 |
-
-
- |
- 合计: |
- |
-
-
-
-
-
-
-
-
- |
- 结算账户 |
- 金额 |
-
-
- |
- 合计: |
- |
-
-
-
-
-
-
-
-
-
+
+
+
+ 采购入库
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | 供应商: |
+
+
+ |
+ 单据日期: |
+
+
+ |
+ 单据编号: |
+
+
+ |
+ |
+ |
+ |
+
+
+ |
+
+
+ |
+
+
+ | 单据备注: |
+
+
+ |
+
+
+ | 优惠率: |
+
+
+ %
+ |
+ 付款优惠: |
+
+
+ |
+ 优惠后金额: |
+
+
+ |
+ 本次付款: |
+
+
+ |
+ |
+
+
+ | 结算账户: |
+
+
+ |
+ 本次欠款: |
+
+
+ |
+ 采购费用: |
+
+
+ |
+ 结算天数: |
+
+
+ |
+ |
+
+
+
+
+
+
+ |
+ 结算账户 |
+ 金额 |
+
+
+ |
+ 合计: |
+ |
+
+
+
+
+
+
+
+
+ |
+ 结算账户 |
+ 金额 |
+
+
+ |
+ 合计: |
+ |
+
+
+
+
+
+
+
+
+
diff --git a/erp_web/pages/reports/account_report.html b/erp_web/pages/reports/account_report.html
index 85a55ee6..bb1d0736 100644
--- a/erp_web/pages/reports/account_report.html
+++ b/erp_web/pages/reports/account_report.html
@@ -1,320 +1,319 @@
-
-
-
- 结算账户查询
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 结算账户查询
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erp_web/pages/reports/buy_in_report.html b/erp_web/pages/reports/buy_in_report.html
index d0e0efa6..0a2011ca 100644
--- a/erp_web/pages/reports/buy_in_report.html
+++ b/erp_web/pages/reports/buy_in_report.html
@@ -1,261 +1,260 @@
-
-
-
- 进货统计
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 进货统计
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erp_web/pages/reports/customer_account.html b/erp_web/pages/reports/customer_account.html
index cc0a7e51..f3966d01 100644
--- a/erp_web/pages/reports/customer_account.html
+++ b/erp_web/pages/reports/customer_account.html
@@ -344,8 +344,7 @@
//报表打印
function print() {
$("#printBtn").off("click").on("click", function () {
- var path = "<%=path %>";
- CreateFormPage('打印报表', $('#tableData'), path);
+ CreateFormPage('打印报表', $('#tableData'));
});
}
diff --git a/erp_web/pages/reports/in_detail.html b/erp_web/pages/reports/in_detail.html
index 7e713b2f..be21a76b 100644
--- a/erp_web/pages/reports/in_detail.html
+++ b/erp_web/pages/reports/in_detail.html
@@ -1,315 +1,314 @@
-
-
-
- 入库明细
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 入库明细
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erp_web/pages/reports/in_material_count.html b/erp_web/pages/reports/in_material_count.html
index 50dc379c..40c61202 100644
--- a/erp_web/pages/reports/in_material_count.html
+++ b/erp_web/pages/reports/in_material_count.html
@@ -1,304 +1,303 @@
-
-
-
- 入库汇总
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 入库汇总
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erp_web/pages/reports/in_out_stock_report.html b/erp_web/pages/reports/in_out_stock_report.html
index a8c006b9..584ebf77 100644
--- a/erp_web/pages/reports/in_out_stock_report.html
+++ b/erp_web/pages/reports/in_out_stock_report.html
@@ -1,420 +1,419 @@
-
-
-
- 库存状况
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 库存状况
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erp_web/pages/reports/out_detail.html b/erp_web/pages/reports/out_detail.html
index d39f35b9..4e46feab 100644
--- a/erp_web/pages/reports/out_detail.html
+++ b/erp_web/pages/reports/out_detail.html
@@ -1,315 +1,314 @@
-
-
-
- 出库明细
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 出库明细
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erp_web/pages/reports/out_material_count.html b/erp_web/pages/reports/out_material_count.html
index e1e7fcc7..7aeba618 100644
--- a/erp_web/pages/reports/out_material_count.html
+++ b/erp_web/pages/reports/out_material_count.html
@@ -1,304 +1,303 @@
-
-
-
- 出库汇总
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 出库汇总
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erp_web/pages/reports/sale_out_report.html b/erp_web/pages/reports/sale_out_report.html
index e35e33e2..f3bcb9ae 100644
--- a/erp_web/pages/reports/sale_out_report.html
+++ b/erp_web/pages/reports/sale_out_report.html
@@ -1,264 +1,263 @@
-
-
-
- 销售统计
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ 销售统计
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/erp_web/pages/reports/vendor_account.html b/erp_web/pages/reports/vendor_account.html
index 8764803c..c5cb9740 100644
--- a/erp_web/pages/reports/vendor_account.html
+++ b/erp_web/pages/reports/vendor_account.html
@@ -343,8 +343,7 @@
//报表打印
function print() {
$("#printBtn").off("click").on("click", function () {
- var path = "<%=path %>";
- CreateFormPage('打印报表', $('#tableData'), path);
+ CreateFormPage('打印报表', $('#tableData'));
});
}
diff --git a/pom.xml b/pom.xml
index c97caa6d..829f3b70 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,7 +42,7 @@
UTF-8
UTF-8
- 1.7
+ 1.8
@@ -96,6 +96,11 @@
commons-httpclient
3.1
+
+ net.sourceforge.jexcelapi
+ jxl
+ 2.6.3
+
@@ -174,9 +179,10 @@
org.apache.maven.plugins
maven-compiler-plugin
+ 3.7.0
- 1.7
- 1.7
+ 1.8
+ 1.8
diff --git a/src/main/conf/start.sh b/src/main/conf/start.sh
new file mode 100644
index 00000000..8d7fafb1
--- /dev/null
+++ b/src/main/conf/start.sh
@@ -0,0 +1 @@
+nohup ./jshERPStart.sh &
\ No newline at end of file
diff --git a/src/main/java/com/jsh/erp/controller/AppController.java b/src/main/java/com/jsh/erp/controller/AppController.java
index fd1fe182..a816648f 100644
--- a/src/main/java/com/jsh/erp/controller/AppController.java
+++ b/src/main/java/com/jsh/erp/controller/AppController.java
@@ -5,13 +5,18 @@ import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.App;
import com.jsh.erp.service.app.AppService;
import com.jsh.erp.service.userBusiness.UserBusinessService;
+import com.jsh.erp.utils.BaseResponseInfo;
+import com.jsh.erp.utils.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
+import java.io.*;
import java.util.List;
+import java.util.Properties;
/**
* @author ji_sheng_hua 752*718*920
@@ -26,14 +31,7 @@ public class AppController {
@Resource
private UserBusinessService userBusinessService;
- /**
- * create by: cjl
- * description:
- * 桌面菜单按钮初始化
- * create time: 2019/1/11 17:01
- * @Param: request
- * @return com.alibaba.fastjson.JSONObject
- */
+
@GetMapping(value = "/findDesk")
public JSONObject findDesk(HttpServletRequest request) {
JSONObject obj = new JSONObject();
@@ -123,4 +121,38 @@ public class AppController {
}
return arr;
}
+
+ /**
+ * 上传图片
+ * @param fileInfo
+ * @param request
+ */
+ @PostMapping(value = "/uploadImg")
+ public BaseResponseInfo uploadImg(MultipartFile fileInfo, @RequestParam("fileInfoName") String fileName,
+ HttpServletRequest request) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ if (fileInfo != null) {
+ String basePath = request.getSession().getServletContext().getRealPath("/"); //默认windows文件路径,linux环境下生成的目录与项目同级,而不是下级
+ String path = basePath + "upload/images/deskIcon/"; //windows环境下的路径
+ Properties pro = System.getProperties();
+ String osName = pro.getProperty("os.name");//获得当前操作系统的名称
+ if("Linux".equals(osName) || "linux".equals(osName) || "LINUX".equals(osName)){
+ path = basePath + "/upload/images/deskIcon/"; //linux环境下的路径
+ }
+ FileUtils.SaveFileFromInputStream(fileInfo.getInputStream(), path, fileName);
+ res.code = 200;
+ res.data = "上传图片成功";
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ res.code = 500;
+ res.data = "获取图片失败";
+ } catch (IOException e) {
+ e.printStackTrace();
+ res.code = 500;
+ res.data = "上传图片失败";
+ }
+ return res;
+ }
}
diff --git a/src/main/java/com/jsh/erp/controller/DepotItemController.java b/src/main/java/com/jsh/erp/controller/DepotItemController.java
index 058ea9db..60adcbd6 100644
--- a/src/main/java/com/jsh/erp/controller/DepotItemController.java
+++ b/src/main/java/com/jsh/erp/controller/DepotItemController.java
@@ -9,11 +9,12 @@ import com.jsh.erp.utils.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
-import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -32,7 +33,8 @@ public class DepotItemController {
@Resource
private DepotItemService depotItemService;
-
+ @Resource
+ private MaterialService materialService;
/**
* 根据材料信息获取
@@ -267,7 +269,26 @@ public class DepotItemController {
}
}
-
+ /**
+ * 查询计量单位信息
+ *
+ * @return
+ */
+ public String findUnitName(Long mId) {
+ String unitName = "";
+ try {
+ unitName = materialService.findUnitName(mId);
+ if (unitName != null) {
+ unitName = unitName.substring(1, unitName.length() - 1);
+ if (unitName.equals("null")) {
+ unitName = "";
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return unitName;
+ }
@GetMapping(value = "/getDetailList")
public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId,
@@ -403,14 +424,12 @@ public class DepotItemController {
if (null != dataList) {
for (DepotItemVo4WithInfoEx diEx : dataList) {
JSONObject item = new JSONObject();
- Double prevSum = sumNumber("入库", pid, diEx.getMaterialid(), monthTime, true) - sumNumber("出库", pid, diEx.getMaterialid(), monthTime, true);
- Double InSum = sumNumber("入库", pid, diEx.getMaterialid(), monthTime, false);
- Double OutSum = sumNumber("出库", pid, diEx.getMaterialid(), monthTime, false);
- Double prevPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, true) - sumPrice("出库", pid, diEx.getMaterialid(), monthTime, true);
- Double InPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, false);
- Double OutPrice = sumPrice("出库", pid, diEx.getMaterialid(), monthTime, false);
- item.put("Id", diEx.getId());
- item.put("MaterialId", diEx.getMaterialid());
+ Double prevSum = sumNumber("入库", pid, diEx.getMId(), monthTime, true) - sumNumber("出库", pid, diEx.getMId(), monthTime, true);
+ Double InSum = sumNumber("入库", pid, diEx.getMId(), monthTime, false);
+ Double OutSum = sumNumber("出库", pid, diEx.getMId(), monthTime, false);
+ Double prevPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, true) - sumPrice("出库", pid, diEx.getMId(), monthTime, true);
+ Double InPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, false);
+ Double OutPrice = sumPrice("出库", pid, diEx.getMId(), monthTime, false);
item.put("MaterialName", diEx.getMName());
item.put("MaterialModel", diEx.getMColor());
//扩展信息
@@ -464,9 +483,9 @@ public class DepotItemController {
Double thisAllPrice = 0.0;
if (null != dataList) {
for (DepotItemVo4WithInfoEx diEx : dataList) {
- Double prevPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, true) - sumPrice("出库", pid, diEx.getMaterialid(), monthTime, true);
- Double InPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, false);
- Double OutPrice = sumPrice("出库", pid, diEx.getMaterialid(), monthTime, false);
+ Double prevPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, true) - sumPrice("出库", pid, diEx.getMId(), monthTime, true);
+ Double InPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, false);
+ Double OutPrice = sumPrice("出库", pid, diEx.getMId(), monthTime, false);
thisAllPrice = thisAllPrice + (prevPrice + InPrice - OutPrice);
}
}
@@ -512,12 +531,10 @@ public class DepotItemController {
if (null != dataList) {
for (DepotItemVo4WithInfoEx diEx : dataList) {
JSONObject item = new JSONObject();
- Double InSum = sumNumberBuyOrSale("入库", "采购", diEx.getMaterialid(), monthTime);
- Double OutSum = sumNumberBuyOrSale("出库", "采购退货", diEx.getMaterialid(), monthTime);
- Double InSumPrice = sumPriceBuyOrSale("入库", "采购", diEx.getMaterialid(), monthTime);
- Double OutSumPrice = sumPriceBuyOrSale("出库", "采购退货", diEx.getMaterialid(), monthTime);
- item.put("Id", diEx.getId());
- item.put("MaterialId", diEx.getMaterialid());
+ Double InSum = sumNumberBuyOrSale("入库", "采购", diEx.getMId(), monthTime);
+ Double OutSum = sumNumberBuyOrSale("出库", "采购退货", diEx.getMId(), monthTime);
+ Double InSumPrice = sumPriceBuyOrSale("入库", "采购", diEx.getMId(), monthTime);
+ Double OutSumPrice = sumPriceBuyOrSale("出库", "采购退货", diEx.getMId(), monthTime);
item.put("MaterialName", diEx.getMName());
item.put("MaterialModel", diEx.getMModel());
//扩展信息
@@ -574,16 +591,14 @@ public class DepotItemController {
if (null != dataList) {
for (DepotItemVo4WithInfoEx diEx : dataList) {
JSONObject item = new JSONObject();
- Double OutSumRetail = sumNumberBuyOrSale("出库", "零售", diEx.getMaterialid(), monthTime);
- Double OutSum = sumNumberBuyOrSale("出库", "销售", diEx.getMaterialid(), monthTime);
- Double InSumRetail = sumNumberBuyOrSale("入库", "零售退货", diEx.getMaterialid(), monthTime);
- Double InSum = sumNumberBuyOrSale("入库", "销售退货", diEx.getMaterialid(), monthTime);
- Double OutSumRetailPrice = sumPriceBuyOrSale("出库", "零售", diEx.getMaterialid(), monthTime);
- Double OutSumPrice = sumPriceBuyOrSale("出库", "销售", diEx.getMaterialid(), monthTime);
- Double InSumRetailPrice = sumPriceBuyOrSale("入库", "零售退货", diEx.getMaterialid(), monthTime);
- Double InSumPrice = sumPriceBuyOrSale("入库", "销售退货", diEx.getMaterialid(), monthTime);
- item.put("Id", diEx.getId());
- item.put("MaterialId", diEx.getMaterialid());
+ Double OutSumRetail = sumNumberBuyOrSale("出库", "零售", diEx.getMId(), monthTime);
+ Double OutSum = sumNumberBuyOrSale("出库", "销售", diEx.getMId(), monthTime);
+ Double InSumRetail = sumNumberBuyOrSale("入库", "零售退货", diEx.getMId(), monthTime);
+ Double InSum = sumNumberBuyOrSale("入库", "销售退货", diEx.getMId(), monthTime);
+ Double OutSumRetailPrice = sumPriceBuyOrSale("出库", "零售", diEx.getMId(), monthTime);
+ Double OutSumPrice = sumPriceBuyOrSale("出库", "销售", diEx.getMId(), monthTime);
+ Double InSumRetailPrice = sumPriceBuyOrSale("入库", "零售退货", diEx.getMId(), monthTime);
+ Double InSumPrice = sumPriceBuyOrSale("入库", "销售退货", diEx.getMId(), monthTime);
item.put("MaterialName", diEx.getMName());
item.put("MaterialModel", diEx.getMModel());
//扩展信息
@@ -640,10 +655,8 @@ public class DepotItemController {
if (null != dataList) {
for (DepotItemVo4WithInfoEx diEx : dataList) {
JSONObject item = new JSONObject();
- Double InSum = sumNumberGift("礼品充值", pid, diEx.getMaterialid(), "in");
- Double OutSum = sumNumberGift("礼品销售", pid, diEx.getMaterialid(), "out");
- item.put("Id", diEx.getId());
- item.put("MaterialId", diEx.getMaterialid());
+ Double InSum = sumNumberGift("礼品充值", pid, diEx.getMId(), "in");
+ Double OutSum = sumNumberGift("礼品销售", pid, diEx.getMId(), "out");
item.put("MaterialName", diEx.getMName());
item.put("MaterialModel", diEx.getMModel());
//扩展信息
@@ -666,6 +679,77 @@ public class DepotItemController {
return res;
}
+ /**
+ * 导出excel表格
+ * @param currentPage
+ * @param pageSize
+ * @param projectId
+ * @param monthTime
+ * @param headIds
+ * @param materialIds
+ * @param request
+ * @param response
+ * @return
+ */
+ @GetMapping(value = "/exportExcel")
+ public BaseResponseInfo exportExcel(@RequestParam("currentPage") Integer currentPage,
+ @RequestParam("pageSize") Integer pageSize,
+ @RequestParam("projectId") Integer projectId,
+ @RequestParam("monthTime") String monthTime,
+ @RequestParam("headIds") String headIds,
+ @RequestParam("materialIds") String materialIds,
+ HttpServletRequest request, HttpServletResponse response) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ Map map = new HashMap();
+ String message = "成功";
+ try {
+ List dataList = depotItemService.findByAll(headIds, materialIds, currentPage, pageSize);
+ //存放数据json数组
+ Integer pid = projectId;
+ String[] names = {"名称", "型号", "单位", "单价", "上月结存数量", "入库数量", "出库数量", "本月结存数量", "结存金额"};
+ String title = "库存报表";
+ List objects = new ArrayList();
+ if (null != dataList) {
+ for (DepotItemVo4WithInfoEx diEx : dataList) {
+ String[] objs = new String[9];
+ Double prevSum = sumNumber("入库", pid, diEx.getMId(), monthTime, true) - sumNumber("出库", pid, diEx.getMId(), monthTime, true);
+ Double InSum = sumNumber("入库", pid, diEx.getMId(), monthTime, false);
+ Double OutSum = sumNumber("出库", pid, diEx.getMId(), monthTime, false);
+ Double prevPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, true) - sumPrice("出库", pid, diEx.getMId(), monthTime, true);
+ Double InPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, false);
+ Double OutPrice = sumPrice("出库", pid, diEx.getMId(), monthTime, false);
+ Double unitPrice = 0.0;
+ if (prevSum + InSum - OutSum != 0.0) {
+ unitPrice = (prevPrice + InPrice - OutPrice) / (prevSum + InSum - OutSum);
+ }
+ Double thisSum = prevSum + InSum - OutSum;
+ Double thisAllPrice = prevPrice + InPrice - OutPrice;
+ objs[0] = diEx.getMName().toString();
+ objs[1] = diEx.getMModel().toString();
+ objs[2] = diEx.getMaterialUnit().toString();
+ objs[3] = unitPrice.toString();
+ objs[4] = prevSum.toString();
+ objs[5] = InSum.toString();
+ objs[6] = OutSum.toString();
+ objs[7] = thisSum.toString();
+ objs[8] = thisAllPrice.toString();
+ objects.add(objs);
+ }
+ }
+ File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
+ ExportExecUtil.showExec(file, file.getName() + "-" + monthTime, response);
+ res.code = 200;
+ } catch (Exception e) {
+ e.printStackTrace();
+ message = "导出失败";
+ res.code = 500;
+ } finally {
+ map.put("message", message);
+ res.data = map;
+ }
+ return res;
+ }
+
/**
* 数量合计
*
diff --git a/src/main/java/com/jsh/erp/controller/MaterialController.java b/src/main/java/com/jsh/erp/controller/MaterialController.java
index f3e52ca3..ba03288a 100644
--- a/src/main/java/com/jsh/erp/controller/MaterialController.java
+++ b/src/main/java/com/jsh/erp/controller/MaterialController.java
@@ -1,180 +1,309 @@
-package com.jsh.erp.controller;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.jsh.erp.datasource.entities.Material;
-import com.jsh.erp.datasource.entities.MaterialVo4Unit;
-import com.jsh.erp.service.material.MaterialService;
-import com.jsh.erp.utils.BaseResponseInfo;
-import com.jsh.erp.utils.ErpInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
-
-/**
- * @author ji|sheng|hua 华夏ERP
- */
-@RestController
-@RequestMapping(value = "/material")
-public class MaterialController {
- private Logger logger = LoggerFactory.getLogger(MaterialController.class);
-
- @Resource
- private MaterialService materialService;
-
- @GetMapping(value = "/checkIsExist")
- public String checkIsExist(@RequestParam("id") Long id, @RequestParam("name") String name,
- @RequestParam("model") String model, @RequestParam("color") String color,
- @RequestParam("standard") String standard, @RequestParam("mfrs") String mfrs,
- @RequestParam("otherField1") String otherField1, @RequestParam("otherField2") String otherField2,
- @RequestParam("otherField3") String otherField3, @RequestParam("unit") String unit,@RequestParam("unitId") Long unitId,
- HttpServletRequest request) {
- Map objectMap = new HashMap();
- int exist = materialService.checkIsExist(id, name, model, color, standard, mfrs,
- otherField1, otherField2, otherField3, unit, unitId);
- if(exist > 0) {
- objectMap.put("status", true);
- } else {
- objectMap.put("status", false);
- }
- return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
- }
-
- /**
- * 批量设置状态-启用或者禁用
- * @param enabled
- * @param materialIDs
- * @param request
- * @return
- */
- @PostMapping(value = "/batchSetEnable")
- public String batchSetEnable(@RequestParam("enabled") Boolean enabled,
- @RequestParam("materialIDs") String materialIDs,
- HttpServletRequest request) {
- Map objectMap = new HashMap();
- int res = materialService.batchSetEnable(enabled, materialIDs);
- if(res > 0) {
- return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
- } else {
- return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
- }
- }
-
- /**
- * 根据id来查询商品名称
- * @param id
- * @param request
- * @return
- */
- @GetMapping(value = "/findById")
- public BaseResponseInfo findById(@RequestParam("id") Long id, HttpServletRequest request) {
- BaseResponseInfo res = new BaseResponseInfo();
- try {
- List list = materialService.findById(id);
- res.code = 200;
- res.data = list;
- } catch(Exception e){
- e.printStackTrace();
- res.code = 500;
- res.data = "获取数据失败";
- }
- return res;
- }
-
- /**
- * 查找商品信息-下拉框
- * @param mpList
- * @param request
- * @return
- */
- @GetMapping(value = "/findBySelect")
- public JSONArray findBySelect(@RequestParam("mpList") String mpList, HttpServletRequest request) {
- JSONArray dataArray = new JSONArray();
- try {
- List dataList = materialService.findBySelect();
- String[] mpArr = mpList.split(",");
- //存放数据json数组
- if (null != dataList) {
- for (MaterialVo4Unit material : dataList) {
- JSONObject item = new JSONObject();
- item.put("Id", material.getId());
- String ratio; //比例
- if (material.getUnitid() == null || material.getUnitid().equals("")) {
- ratio = "";
- } else {
- ratio = material.getUnitName();
- ratio = ratio.substring(ratio.indexOf("("));
- }
- //品名/型号/扩展信息/包装
- String MaterialName = material.getName() + ((material.getModel() == null || material.getModel().equals("")) ? "" : "(" + material.getModel() + ")");
- for (int i = 0; i < mpArr.length; i++) {
- if (mpArr[i].equals("颜色")) {
- MaterialName = MaterialName + ((material.getColor() == null || material.getColor().equals("")) ? "" : "(" + material.getColor() + ")");
- }
- if (mpArr[i].equals("规格")) {
- MaterialName = MaterialName + ((material.getStandard() == null || material.getStandard().equals("")) ? "" : "(" + material.getStandard() + ")");
- }
- if (mpArr[i].equals("制造商")) {
- MaterialName = MaterialName + ((material.getMfrs() == null || material.getMfrs().equals("")) ? "" : "(" + material.getMfrs() + ")");
- }
- if (mpArr[i].equals("自定义1")) {
- MaterialName = MaterialName + ((material.getOtherfield1() == null || material.getOtherfield1().equals("")) ? "" : "(" + material.getOtherfield1() + ")");
- }
- if (mpArr[i].equals("自定义2")) {
- MaterialName = MaterialName + ((material.getOtherfield2() == null || material.getOtherfield2().equals("")) ? "" : "(" + material.getOtherfield2() + ")");
- }
- if (mpArr[i].equals("自定义3")) {
- MaterialName = MaterialName + ((material.getOtherfield3() == null || material.getOtherfield3().equals("")) ? "" : "(" + material.getOtherfield3() + ")");
- }
- }
- MaterialName = MaterialName + ((material.getUnit() == null || material.getUnit().equals("")) ? "" : "(" + material.getUnit() + ")") + ratio;
- item.put("MaterialName", MaterialName);
- dataArray.add(item);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return dataArray;
- }
-
-
- /**
- * 查找商品信息-统计排序
- * @param request
- * @return
- */
- @GetMapping(value = "/findByOrder")
- public BaseResponseInfo findByOrder(HttpServletRequest request) {
- BaseResponseInfo res = new BaseResponseInfo();
- Map map = new HashMap();
- try {
- List dataList = materialService.findByOrder();
- String mId = "";
- if (null != dataList) {
- for (Material material : dataList) {
- mId = mId + material.getId() + ",";
- }
- }
- if (mId != "") {
- mId = mId.substring(0, mId.lastIndexOf(","));
- }
- map.put("mIds", mId);
- res.code = 200;
- res.data = map;
- } catch(Exception e){
- e.printStackTrace();
- res.code = 500;
- res.data = "获取数据失败";
- }
- return res;
- }
-}
+package com.jsh.erp.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.jsh.erp.datasource.entities.Material;
+import com.jsh.erp.datasource.entities.MaterialVo4Unit;
+import com.jsh.erp.service.material.MaterialService;
+import com.jsh.erp.utils.*;
+import jxl.Sheet;
+import jxl.Workbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
+
+/**
+ * @author ji|sheng|hua 华夏ERP
+ */
+@RestController
+@RequestMapping(value = "/material")
+public class MaterialController {
+ private Logger logger = LoggerFactory.getLogger(MaterialController.class);
+
+ @Resource
+ private MaterialService materialService;
+
+ @GetMapping(value = "/checkIsExist")
+ public String checkIsExist(@RequestParam("id") Long id, @RequestParam("name") String name,
+ @RequestParam("model") String model, @RequestParam("color") String color,
+ @RequestParam("standard") String standard, @RequestParam("mfrs") String mfrs,
+ @RequestParam("otherField1") String otherField1, @RequestParam("otherField2") String otherField2,
+ @RequestParam("otherField3") String otherField3, @RequestParam("unit") String unit,@RequestParam("unitId") Long unitId,
+ HttpServletRequest request) {
+ Map objectMap = new HashMap();
+ int exist = materialService.checkIsExist(id, name, model, color, standard, mfrs,
+ otherField1, otherField2, otherField3, unit, unitId);
+ if(exist > 0) {
+ objectMap.put("status", true);
+ } else {
+ objectMap.put("status", false);
+ }
+ return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
+ }
+
+ /**
+ * 批量设置状态-启用或者禁用
+ * @param enabled
+ * @param materialIDs
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/batchSetEnable")
+ public String batchSetEnable(@RequestParam("enabled") Boolean enabled,
+ @RequestParam("materialIDs") String materialIDs,
+ HttpServletRequest request) {
+ Map objectMap = new HashMap();
+ int res = materialService.batchSetEnable(enabled, materialIDs);
+ if(res > 0) {
+ return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
+ } else {
+ return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
+ }
+ }
+
+ /**
+ * 根据id来查询商品名称
+ * @param id
+ * @param request
+ * @return
+ */
+ @GetMapping(value = "/findById")
+ public BaseResponseInfo findById(@RequestParam("id") Long id, HttpServletRequest request) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ List list = materialService.findById(id);
+ res.code = 200;
+ res.data = list;
+ } catch(Exception e){
+ e.printStackTrace();
+ res.code = 500;
+ res.data = "获取数据失败";
+ }
+ return res;
+ }
+
+ /**
+ * 查找商品信息-下拉框
+ * @param mpList
+ * @param request
+ * @return
+ */
+ @GetMapping(value = "/findBySelect")
+ public JSONArray findBySelect(@RequestParam("mpList") String mpList, HttpServletRequest request) {
+ JSONArray dataArray = new JSONArray();
+ try {
+ List dataList = materialService.findBySelect();
+ String[] mpArr = mpList.split(",");
+ //存放数据json数组
+ if (null != dataList) {
+ for (MaterialVo4Unit material : dataList) {
+ JSONObject item = new JSONObject();
+ item.put("Id", material.getId());
+ String ratio; //比例
+ if (material.getUnitid() == null || material.getUnitid().equals("")) {
+ ratio = "";
+ } else {
+ ratio = material.getUnitName();
+ ratio = ratio.substring(ratio.indexOf("("));
+ }
+ //品名/型号/扩展信息/包装
+ String MaterialName = material.getName() + ((material.getModel() == null || material.getModel().equals("")) ? "" : "(" + material.getModel() + ")");
+ for (int i = 0; i < mpArr.length; i++) {
+ if (mpArr[i].equals("颜色")) {
+ MaterialName = MaterialName + ((material.getColor() == null || material.getColor().equals("")) ? "" : "(" + material.getColor() + ")");
+ }
+ if (mpArr[i].equals("规格")) {
+ MaterialName = MaterialName + ((material.getStandard() == null || material.getStandard().equals("")) ? "" : "(" + material.getStandard() + ")");
+ }
+ if (mpArr[i].equals("制造商")) {
+ MaterialName = MaterialName + ((material.getMfrs() == null || material.getMfrs().equals("")) ? "" : "(" + material.getMfrs() + ")");
+ }
+ if (mpArr[i].equals("自定义1")) {
+ MaterialName = MaterialName + ((material.getOtherfield1() == null || material.getOtherfield1().equals("")) ? "" : "(" + material.getOtherfield1() + ")");
+ }
+ if (mpArr[i].equals("自定义2")) {
+ MaterialName = MaterialName + ((material.getOtherfield2() == null || material.getOtherfield2().equals("")) ? "" : "(" + material.getOtherfield2() + ")");
+ }
+ if (mpArr[i].equals("自定义3")) {
+ MaterialName = MaterialName + ((material.getOtherfield3() == null || material.getOtherfield3().equals("")) ? "" : "(" + material.getOtherfield3() + ")");
+ }
+ }
+ MaterialName = MaterialName + ((material.getUnit() == null || material.getUnit().equals("")) ? "" : "(" + material.getUnit() + ")") + ratio;
+ item.put("MaterialName", MaterialName);
+ dataArray.add(item);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return dataArray;
+ }
+
+
+ /**
+ * 查找商品信息-统计排序
+ * @param request
+ * @return
+ */
+ @GetMapping(value = "/findByOrder")
+ public BaseResponseInfo findByOrder(HttpServletRequest request) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ Map map = new HashMap();
+ try {
+ List dataList = materialService.findByOrder();
+ String mId = "";
+ if (null != dataList) {
+ for (Material material : dataList) {
+ mId = mId + material.getId() + ",";
+ }
+ }
+ if (mId != "") {
+ mId = mId.substring(0, mId.lastIndexOf(","));
+ }
+ map.put("mIds", mId);
+ res.code = 200;
+ res.data = map;
+ } catch(Exception e){
+ e.printStackTrace();
+ res.code = 500;
+ res.data = "获取数据失败";
+ }
+ return res;
+ }
+
+ /**
+ * 生成excel表格
+ * @param name
+ * @param model
+ * @param categoryId
+ * @param categoryIds
+ * @param request
+ * @param response
+ * @return
+ */
+ @GetMapping(value = "/exportExcel")
+ public BaseResponseInfo exportExcel(@RequestParam("name") String name,
+ @RequestParam("model") String model,
+ @RequestParam("categoryId") Long categoryId,
+ @RequestParam("categoryIds") String categoryIds,
+ HttpServletRequest request, HttpServletResponse response) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ Map map = new HashMap();
+ String message = "成功";
+ try {
+ List dataList = materialService.findByAll(name, model, categoryId, categoryIds);
+ String[] names = {"品名", "类型", "型号", "安全存量", "单位", "零售价", "最低售价", "预计采购价", "批发价", "备注", "状态"};
+ String title = "商品信息";
+ List objects = new ArrayList();
+ if (null != dataList) {
+ for (MaterialVo4Unit m : dataList) {
+ String[] objs = new String[11];
+ objs[0] = m.getName();
+ objs[1] = m.getCategoryName();
+ objs[2] = m.getModel();
+ objs[3] = m.getSafetystock() == null? "" : m.getSafetystock().toString();
+ objs[4] = m.getUnit();
+ objs[5] = m.getRetailprice() == null ? "" : m.getRetailprice().toString();
+ objs[6] = m.getLowprice() == null ? "" : m.getLowprice().toString();
+ objs[7] = m.getPresetpriceone() == null ? "" : m.getPresetpriceone().toString();
+ objs[8] = m.getPresetpricetwo() == null ? "" : m.getPresetpricetwo().toString();
+ objs[9] = m.getRemark();
+ objs[10] = m.getEnabled() ? "启用" : "禁用";
+ objects.add(objs);
+ }
+ }
+ File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
+ ExportExecUtil.showExec(file, file.getName(), response);
+ res.code = 200;
+ } catch (Exception e) {
+ e.printStackTrace();
+ message = "导出失败";
+ res.code = 500;
+ } finally {
+ map.put("message", message);
+ res.data = map;
+ }
+ return res;
+ }
+
+ /**
+ * excel表格导入
+ * @param materialFile
+ * @param request
+ * @param response
+ * @return
+ */
+ @PostMapping(value = "/importExcel")
+ public void importExcel(MultipartFile materialFile,
+ HttpServletRequest request, HttpServletResponse response) throws Exception{
+ BaseResponseInfo info = new BaseResponseInfo();
+ Map data = new HashMap();
+ String message = "成功";
+ try {
+ Sheet src = null;
+ //文件合法性校验
+ try {
+ Workbook workbook = Workbook.getWorkbook(materialFile.getInputStream());
+ src = workbook.getSheet(0);
+ } catch (Exception e) {
+ message = "导入文件不合法,请检查";
+ data.put("message", message);
+ info.code = 400;
+ info.data = data;
+ }
+ //读取所有的摄像机编码
+ //每行中数据顺序 "品名","类型","型号","安全存量","单位","零售价","最低售价","预计采购价","批发价","备注","状态"
+ List mList = new ArrayList();
+ for (int i = 1; i < src.getRows(); i++) {
+ Material m = new Material();
+ m.setName(ExcelUtils.getContent(src, i, 0));
+ m.setCategoryid(1l); //根目录
+ m.setModel(ExcelUtils.getContent(src, i, 2));
+ String safetyStock = ExcelUtils.getContent(src, i, 3);
+ m.setSafetystock(parseDoubleEx(safetyStock));
+ m.setUnit(ExcelUtils.getContent(src, i, 4));
+ String retailprice = ExcelUtils.getContent(src, i, 5);
+ m.setRetailprice(parseDoubleEx(retailprice));
+ String lowPrice = ExcelUtils.getContent(src, i, 6);
+ m.setLowprice(parseDoubleEx(lowPrice));
+ String presetpriceone = ExcelUtils.getContent(src, i, 7);
+ m.setPresetpriceone(parseDoubleEx(presetpriceone));
+ String presetpricetwo = ExcelUtils.getContent(src, i, 8);
+ m.setPresetpricetwo(parseDoubleEx(presetpricetwo));
+ m.setRemark(ExcelUtils.getContent(src, i, 9));
+ String enabled = ExcelUtils.getContent(src, i, 10);
+ m.setEnabled(enabled.equals("启用")? true: false);
+ mList.add(m);
+ }
+ info = materialService.importExcel(mList);
+ } catch (Exception e) {
+ e.printStackTrace();
+ message = "导入失败";
+ info.code = 500;
+ data.put("message", message);
+ info.data = data;
+ }
+ response.sendRedirect("../pages/materials/material.html");
+ }
+
+ public Double parseDoubleEx(String str){
+ if(!StringUtil.isEmpty(str)) {
+ return Double.parseDouble(str);
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/com/jsh/erp/controller/SupplierController.java b/src/main/java/com/jsh/erp/controller/SupplierController.java
index d2dc0fec..bdab7c99 100644
--- a/src/main/java/com/jsh/erp/controller/SupplierController.java
+++ b/src/main/java/com/jsh/erp/controller/SupplierController.java
@@ -1,262 +1,434 @@
-package com.jsh.erp.controller;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.jsh.erp.datasource.entities.Supplier;
-import com.jsh.erp.service.supplier.SupplierService;
-import com.jsh.erp.service.userBusiness.UserBusinessService;
-import com.jsh.erp.utils.BaseResponseInfo;
-import com.jsh.erp.utils.ErpInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.dao.DataAccessException;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
-
-/**
- * @author ji|sheng|hua 华夏erp
- */
-@RestController
-@RequestMapping(value = "/supplier")
-public class SupplierController {
- private Logger logger = LoggerFactory.getLogger(SupplierController.class);
-
- @Resource
- private SupplierService supplierService;
-
- @Resource
- private UserBusinessService userBusinessService;
-
- /**
- * 更新供应商-只更新预付款,其余用原来的值
- * @param supplierId
- * @param advanceIn
- * @param request
- * @return
- */
- @PostMapping(value = "/updateAdvanceIn")
- public String updateAdvanceIn(@RequestParam("supplierId") Long supplierId,
- @RequestParam("advanceIn") Double advanceIn,
- HttpServletRequest request) {
- Map objectMap = new HashMap();
- int res = supplierService.updateAdvanceIn(supplierId, advanceIn);
- if(res > 0) {
- return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
- } else {
- return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
- }
- }
-
- /**
- * 查找客户信息-下拉框
- * @param request
- * @return
- */
- @PostMapping(value = "/findBySelect_cus")
- public JSONArray findBySelectCus(HttpServletRequest request) {
- JSONArray arr = new JSONArray();
- try {
- List supplierList = supplierService.findBySelectCus();
- JSONArray dataArray = new JSONArray();
- if (null != supplierList) {
- for (Supplier supplier : supplierList) {
- JSONObject item = new JSONObject();
- //勾选判断1
- Boolean flag = false;
- try {
- flag = userBusinessService.checkIsUserBusinessExist(null, null, "[" + supplier.getId().toString() + "]");
- } catch (DataAccessException e) {
- logger.error(">>>>>>>>>>>>>>>>>查询用户对应的客户:存在异常!");
- }
- if (flag == true) {
- item.put("id", supplier.getId());
- item.put("supplier", supplier.getSupplier()); //客户名称
- dataArray.add(item);
- }
- }
- }
- arr = dataArray;
- } catch(Exception e){
- e.printStackTrace();
- }
- return arr;
- }
-
- /**
- * 查找供应商信息-下拉框
- * @param request
- * @return
- */
- @PostMapping(value = "/findBySelect_sup")
- public JSONArray findBySelectSup(HttpServletRequest request) {
- JSONArray arr = new JSONArray();
- try {
- List supplierList = supplierService.findBySelectSup();
- JSONArray dataArray = new JSONArray();
- if (null != supplierList) {
- for (Supplier supplier : supplierList) {
- JSONObject item = new JSONObject();
- item.put("id", supplier.getId());
- //供应商名称
- item.put("supplier", supplier.getSupplier());
- dataArray.add(item);
- }
- }
- arr = dataArray;
- } catch(Exception e){
- e.printStackTrace();
- }
- return arr;
- }
-
- /**
- * 查找会员信息-下拉框
- * @param request
- * @return
- */
- @PostMapping(value = "/findBySelect_retail")
- public JSONArray findBySelectRetail(HttpServletRequest request) {
- JSONArray arr = new JSONArray();
- try {
- List supplierList = supplierService.findBySelectRetail();
- JSONArray dataArray = new JSONArray();
- if (null != supplierList) {
- for (Supplier supplier : supplierList) {
- JSONObject item = new JSONObject();
- item.put("id", supplier.getId());
- //客户名称
- item.put("supplier", supplier.getSupplier());
- item.put("advanceIn", supplier.getAdvancein()); //预付款金额
- dataArray.add(item);
- }
- }
- arr = dataArray;
- } catch(Exception e){
- e.printStackTrace();
- }
- return arr;
- }
-
- /**
- * 根据id查找信息
- * @param supplierId
- * @param request
- * @return
- */
- @GetMapping(value = "/findById")
- public BaseResponseInfo findById(@RequestParam("supplierId") Long supplierId,
- HttpServletRequest request) {
- BaseResponseInfo res = new BaseResponseInfo();
- try {
- JSONArray dataArray = new JSONArray();
- List dataList = supplierService.findById(supplierId);
- if (null != dataList) {
- for (Supplier supplier : dataList) {
- JSONObject item = new JSONObject();
- item.put("id", supplier.getId());
- //名称
- item.put("supplier", supplier.getSupplier());
- item.put("type", supplier.getType());
- item.put("contacts", supplier.getContacts());
- item.put("phonenum", supplier.getPhonenum());
- item.put("email", supplier.getEmail());
- item.put("AdvanceIn", supplier.getAdvancein());
- item.put("BeginNeedGet", supplier.getBeginneedget());
- item.put("BeginNeedPay", supplier.getBeginneedpay());
- item.put("isystem", supplier.getIsystem() == (short) 0 ? "是" : "否");
- item.put("description", supplier.getDescription());
- item.put("fax", supplier.getFax());
- item.put("telephone", supplier.getTelephone());
- item.put("address", supplier.getAddress());
- item.put("taxNum", supplier.getTaxnum());
- item.put("bankName", supplier.getBankname());
- item.put("accountNumber", supplier.getAccountnumber());
- item.put("taxRate", supplier.getTaxrate());
- item.put("enabled", supplier.getEnabled());
- dataArray.add(item);
- }
- res.code = 200;
- res.data = dataArray;
- }
- } catch (Exception e) {
- e.printStackTrace();
- res.code = 500;
- res.data = "获取数据失败";
- }
- return res;
- }
-
- /**
- * 批量设置状态-启用或者禁用
- * @param enabled
- * @param supplierIDs
- * @param request
- * @return
- */
- @PostMapping(value = "/batchSetEnable")
- public String batchSetEnable(@RequestParam("enabled") Boolean enabled,
- @RequestParam("supplierIDs") String supplierIDs,
- HttpServletRequest request) {
- Map objectMap = new HashMap();
- int res = supplierService.batchSetEnable(enabled, supplierIDs);
- if(res > 0) {
- return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
- } else {
- return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
- }
- }
-
- /**
- * 用户对应客户显示
- * @param type
- * @param keyId
- * @param request
- * @return
- */
- @PostMapping(value = "/findUserCustomer")
- public JSONArray findUserCustomer(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
- HttpServletRequest request) {
- JSONArray arr = new JSONArray();
- try {
- List dataList = supplierService.findUserCustomer();
- //开始拼接json数据
- JSONObject outer = new JSONObject();
- outer.put("id", 1);
- outer.put("text", "客户列表");
- outer.put("state", "open");
- //存放数据json数组
- JSONArray dataArray = new JSONArray();
- if (null != dataList) {
- for (Supplier supplier : dataList) {
- JSONObject item = new JSONObject();
- item.put("id", supplier.getId());
- item.put("text", supplier.getSupplier());
- //勾选判断1
- Boolean flag = false;
- try {
- flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + supplier.getId().toString() + "]");
- } catch (Exception e) {
- logger.error(">>>>>>>>>>>>>>>>>设置用户对应的客户:类型" + type + " KeyId为: " + keyId + " 存在异常!");
- }
- if (flag == true) {
- item.put("checked", true);
- }
- //结束
- dataArray.add(item);
- }
- }
- outer.put("children", dataArray);
- arr.add(outer);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return arr;
- }
-}
+package com.jsh.erp.controller;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.jsh.erp.datasource.entities.Supplier;
+import com.jsh.erp.service.supplier.SupplierService;
+import com.jsh.erp.service.userBusiness.UserBusinessService;
+import com.jsh.erp.utils.*;
+import jxl.Sheet;
+import jxl.Workbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.dao.DataAccessException;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
+
+/**
+ * @author ji|sheng|hua 华夏erp
+ */
+@RestController
+@RequestMapping(value = "/supplier")
+public class SupplierController {
+ private Logger logger = LoggerFactory.getLogger(SupplierController.class);
+
+ @Resource
+ private SupplierService supplierService;
+
+ @Resource
+ private UserBusinessService userBusinessService;
+
+ /**
+ * 更新供应商-只更新预付款,其余用原来的值
+ * @param supplierId
+ * @param advanceIn
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/updateAdvanceIn")
+ public String updateAdvanceIn(@RequestParam("supplierId") Long supplierId,
+ @RequestParam("advanceIn") Double advanceIn,
+ HttpServletRequest request) {
+ Map objectMap = new HashMap();
+ int res = supplierService.updateAdvanceIn(supplierId, advanceIn);
+ if(res > 0) {
+ return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
+ } else {
+ return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
+ }
+ }
+
+ /**
+ * 查找客户信息-下拉框
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/findBySelect_cus")
+ public JSONArray findBySelectCus(HttpServletRequest request) {
+ JSONArray arr = new JSONArray();
+ try {
+ List supplierList = supplierService.findBySelectCus();
+ JSONArray dataArray = new JSONArray();
+ if (null != supplierList) {
+ for (Supplier supplier : supplierList) {
+ JSONObject item = new JSONObject();
+ //勾选判断1
+ Boolean flag = false;
+ try {
+ flag = userBusinessService.checkIsUserBusinessExist(null, null, "[" + supplier.getId().toString() + "]");
+ } catch (DataAccessException e) {
+ logger.error(">>>>>>>>>>>>>>>>>查询用户对应的客户:存在异常!");
+ }
+ if (flag == true) {
+ item.put("id", supplier.getId());
+ item.put("supplier", supplier.getSupplier()); //客户名称
+ dataArray.add(item);
+ }
+ }
+ }
+ arr = dataArray;
+ } catch(Exception e){
+ e.printStackTrace();
+ }
+ return arr;
+ }
+
+ /**
+ * 查找供应商信息-下拉框
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/findBySelect_sup")
+ public JSONArray findBySelectSup(HttpServletRequest request) {
+ JSONArray arr = new JSONArray();
+ try {
+ List supplierList = supplierService.findBySelectSup();
+ JSONArray dataArray = new JSONArray();
+ if (null != supplierList) {
+ for (Supplier supplier : supplierList) {
+ JSONObject item = new JSONObject();
+ item.put("id", supplier.getId());
+ //供应商名称
+ item.put("supplier", supplier.getSupplier());
+ dataArray.add(item);
+ }
+ }
+ arr = dataArray;
+ } catch(Exception e){
+ e.printStackTrace();
+ }
+ return arr;
+ }
+
+ /**
+ * 查找会员信息-下拉框
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/findBySelect_retail")
+ public JSONArray findBySelectRetail(HttpServletRequest request) {
+ JSONArray arr = new JSONArray();
+ try {
+ List supplierList = supplierService.findBySelectRetail();
+ JSONArray dataArray = new JSONArray();
+ if (null != supplierList) {
+ for (Supplier supplier : supplierList) {
+ JSONObject item = new JSONObject();
+ item.put("id", supplier.getId());
+ //客户名称
+ item.put("supplier", supplier.getSupplier());
+ item.put("advanceIn", supplier.getAdvancein()); //预付款金额
+ dataArray.add(item);
+ }
+ }
+ arr = dataArray;
+ } catch(Exception e){
+ e.printStackTrace();
+ }
+ return arr;
+ }
+
+ /**
+ * 根据id查找信息
+ * @param supplierId
+ * @param request
+ * @return
+ */
+ @GetMapping(value = "/findById")
+ public BaseResponseInfo findById(@RequestParam("supplierId") Long supplierId,
+ HttpServletRequest request) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ try {
+ JSONArray dataArray = new JSONArray();
+ List dataList = supplierService.findById(supplierId);
+ if (null != dataList) {
+ for (Supplier supplier : dataList) {
+ JSONObject item = new JSONObject();
+ item.put("id", supplier.getId());
+ //名称
+ item.put("supplier", supplier.getSupplier());
+ item.put("type", supplier.getType());
+ item.put("contacts", supplier.getContacts());
+ item.put("phonenum", supplier.getPhonenum());
+ item.put("email", supplier.getEmail());
+ item.put("AdvanceIn", supplier.getAdvancein());
+ item.put("BeginNeedGet", supplier.getBeginneedget());
+ item.put("BeginNeedPay", supplier.getBeginneedpay());
+ item.put("isystem", supplier.getIsystem() == (short) 0 ? "是" : "否");
+ item.put("description", supplier.getDescription());
+ item.put("fax", supplier.getFax());
+ item.put("telephone", supplier.getTelephone());
+ item.put("address", supplier.getAddress());
+ item.put("taxNum", supplier.getTaxnum());
+ item.put("bankName", supplier.getBankname());
+ item.put("accountNumber", supplier.getAccountnumber());
+ item.put("taxRate", supplier.getTaxrate());
+ item.put("enabled", supplier.getEnabled());
+ dataArray.add(item);
+ }
+ res.code = 200;
+ res.data = dataArray;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ res.code = 500;
+ res.data = "获取数据失败";
+ }
+ return res;
+ }
+
+ /**
+ * 批量设置状态-启用或者禁用
+ * @param enabled
+ * @param supplierIDs
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/batchSetEnable")
+ public String batchSetEnable(@RequestParam("enabled") Boolean enabled,
+ @RequestParam("supplierIDs") String supplierIDs,
+ HttpServletRequest request) {
+ Map objectMap = new HashMap();
+ int res = supplierService.batchSetEnable(enabled, supplierIDs);
+ if(res > 0) {
+ return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
+ } else {
+ return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
+ }
+ }
+
+ /**
+ * 用户对应客户显示
+ * @param type
+ * @param keyId
+ * @param request
+ * @return
+ */
+ @PostMapping(value = "/findUserCustomer")
+ public JSONArray findUserCustomer(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
+ HttpServletRequest request) {
+ JSONArray arr = new JSONArray();
+ try {
+ List dataList = supplierService.findUserCustomer();
+ //开始拼接json数据
+ JSONObject outer = new JSONObject();
+ outer.put("id", 1);
+ outer.put("text", "客户列表");
+ outer.put("state", "open");
+ //存放数据json数组
+ JSONArray dataArray = new JSONArray();
+ if (null != dataList) {
+ for (Supplier supplier : dataList) {
+ JSONObject item = new JSONObject();
+ item.put("id", supplier.getId());
+ item.put("text", supplier.getSupplier());
+ //勾选判断1
+ Boolean flag = false;
+ try {
+ flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + supplier.getId().toString() + "]");
+ } catch (Exception e) {
+ logger.error(">>>>>>>>>>>>>>>>>设置用户对应的客户:类型" + type + " KeyId为: " + keyId + " 存在异常!");
+ }
+ if (flag == true) {
+ item.put("checked", true);
+ }
+ //结束
+ dataArray.add(item);
+ }
+ }
+ outer.put("children", dataArray);
+ arr.add(outer);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return arr;
+ }
+
+ /**
+ * 生成excel表格
+ * @param supplier
+ * @param type
+ * @param phonenum
+ * @param telephone
+ * @param description
+ * @param request
+ * @param response
+ * @return
+ */
+ @GetMapping(value = "/exportExcel")
+ public BaseResponseInfo exportExcel(@RequestParam("supplier") String supplier,
+ @RequestParam("type") String type,
+ @RequestParam("phonenum") String phonenum,
+ @RequestParam("telephone") String telephone,
+ @RequestParam("description") String description,
+ HttpServletRequest request, HttpServletResponse response) {
+ BaseResponseInfo res = new BaseResponseInfo();
+ Map map = new HashMap();
+ String message = "成功";
+ try {
+ List dataList = supplierService.findByAll(supplier, type, phonenum, telephone, description);
+ String[] names = {"名称", "类型", "联系人", "电话", "电子邮箱", "预收款", "期初应收", "期初应付", "备注", "传真", "手机", "地址", "纳税人识别号", "开户行", "账号", "税率", "状态"};
+ String title = "信息报表";
+ List objects = new ArrayList();
+ if (null != dataList) {
+ for (Supplier s : dataList) {
+ String[] objs = new String[17];
+ objs[0] = s.getSupplier();
+ objs[1] = s.getType();
+ objs[2] = s.getContacts();
+ objs[3] = s.getPhonenum();
+ objs[4] = s.getEmail();
+ objs[5] = s.getAdvancein() == null? "" : s.getAdvancein().toString();
+ objs[6] = s.getBeginneedget() == null? "" : s.getBeginneedget().toString();
+ objs[7] = s.getBeginneedpay() == null? "" : s.getBeginneedpay().toString();
+ objs[8] = s.getDescription();
+ objs[9] = s.getFax();
+ objs[10] = s.getTelephone();
+ objs[11] = s.getAddress();
+ objs[12] = s.getTaxnum();
+ objs[13] = s.getBankname();
+ objs[14] = s.getAccountnumber();
+ objs[15] = s.getTaxrate() == null? "" : s.getTaxrate().toString();
+ objs[16] = s.getEnabled() ? "启用" : "禁用";
+ objects.add(objs);
+ }
+ }
+ File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
+ ExportExecUtil.showExec(file, file.getName(), response);
+ res.code = 200;
+ } catch (Exception e) {
+ e.printStackTrace();
+ message = "导出失败";
+ res.code = 500;
+ } finally {
+ map.put("message", message);
+ res.data = map;
+ }
+ return res;
+ }
+
+ /**
+ * 导入excel表格-供应商
+ * @param supplierFile
+ * @param request
+ * @param response
+ * @return
+ */
+ @PostMapping(value = "/importExcelVendor")
+ public void importExcelVendor(MultipartFile supplierFile,
+ HttpServletRequest request, HttpServletResponse response) throws Exception{
+ importFun(supplierFile);
+ response.sendRedirect("../pages/manage/vendor.html");
+ }
+
+ /**
+ * 导入excel表格-客户
+ * @param supplierFile
+ * @param request
+ * @param response
+ * @return
+ */
+ @PostMapping(value = "/importExcelCustomer")
+ public void importExcelCustomer(MultipartFile supplierFile,
+ HttpServletRequest request, HttpServletResponse response) throws Exception{
+ importFun(supplierFile);
+ response.sendRedirect("../pages/manage/customer.html");
+ }
+
+ /**
+ * 导入excel表格-会员
+ * @param supplierFile
+ * @param request
+ * @param response
+ * @return
+ */
+ @PostMapping(value = "/importExcelMember")
+ public void importExcelMember(MultipartFile supplierFile,
+ HttpServletRequest request, HttpServletResponse response) throws Exception{
+ importFun(supplierFile);
+ response.sendRedirect("../pages/manage/member.html");
+ }
+
+ public String importFun(MultipartFile supplierFile){
+ BaseResponseInfo info = new BaseResponseInfo();
+ Map data = new HashMap();
+ String message = "成功";
+ try {
+ Sheet src = null;
+ //文件合法性校验
+ try {
+ Workbook workbook = Workbook.getWorkbook(supplierFile.getInputStream());
+ src = workbook.getSheet(0);
+ } catch (Exception e) {
+ message = "导入文件不合法,请检查";
+ data.put("message", message);
+ info.code = 400;
+ info.data = data;
+ }
+ //读取所有的摄像机编码
+ //每行中数据顺序 "名称","类型","联系人","电话","电子邮箱","预收款","期初应收","期初应付","备注","传真","手机","地址","纳税人识别号","开户行","账号","税率","状态"
+ List sList = new ArrayList();
+ for (int i = 1; i < src.getRows(); i++) {
+ Supplier s = new Supplier();
+ s.setSupplier(ExcelUtils.getContent(src, i, 0));
+ s.setType(ExcelUtils.getContent(src, i, 1));
+ s.setContacts(ExcelUtils.getContent(src, i, 2));
+ s.setPhonenum(ExcelUtils.getContent(src, i, 3));
+ s.setEmail(ExcelUtils.getContent(src, i, 4));
+ s.setAdvancein(parseDoubleEx(ExcelUtils.getContent(src, i, 5)));
+ s.setBeginneedget(parseDoubleEx(ExcelUtils.getContent(src, i, 6)));
+ s.setBeginneedpay(parseDoubleEx(ExcelUtils.getContent(src, i, 7)));
+ s.setDescription(ExcelUtils.getContent(src, i, 8));
+ s.setFax(ExcelUtils.getContent(src, i, 9));
+ s.setTelephone(ExcelUtils.getContent(src, i, 10));
+ s.setAddress(ExcelUtils.getContent(src, i, 11));
+ s.setTaxnum(ExcelUtils.getContent(src, i, 12));
+ s.setBankname(ExcelUtils.getContent(src, i, 13));
+ s.setAccountnumber(ExcelUtils.getContent(src, i, 14));
+ s.setTaxrate(parseDoubleEx(ExcelUtils.getContent(src, i, 15)));
+ String enabled = ExcelUtils.getContent(src, i, 16);
+ s.setEnabled(enabled.equals("启用")? true: false);
+ s.setIsystem(Byte.parseByte("1"));
+ sList.add(s);
+ }
+ info = supplierService.importExcel(sList);
+ } catch (Exception e) {
+ e.printStackTrace();
+ message = "导入失败";
+ info.code = 500;
+ data.put("message", message);
+ info.data = data;
+ }
+ return null;
+ }
+
+ public Double parseDoubleEx(String str){
+ if(!StringUtil.isEmpty(str)) {
+ return Double.parseDouble(str);
+ } else {
+ return null;
+ }
+ }
+
+}
diff --git a/src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java b/src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java
index 697dd3e1..6fbc0c7c 100644
--- a/src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java
+++ b/src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java
@@ -1,364 +1,374 @@
-package com.jsh.erp.datasource.entities;
-
-public class DepotItemVo4WithInfoEx {
-
- private Long id;
-
- private Long headerid;
-
- private Long materialid;
-
- private String munit;
-
- private Double opernumber;
-
- private Double basicnumber;
-
- private Double unitprice;
-
- private Double taxunitprice;
-
- private Double allprice;
-
- private String remark;
-
- private String img;
-
- private Double incidentals;
-
- private Long depotid;
-
- private Long anotherdepotid;
-
- private Double taxrate;
-
- private Double taxmoney;
-
- private Double taxlastmoney;
-
- private String otherfield1;
-
- private String otherfield2;
-
- private String otherfield3;
-
- private String otherfield4;
-
- private String otherfield5;
-
- private String mtype;
-
- private String MName;
-
- private String MModel;
-
- private String MaterialUnit;
-
- private String MColor;
-
- private String MStandard;
-
- private String MMfrs;
-
- private String MOtherField1;
-
- private String MOtherField2;
-
- private String MOtherField3;
-
- private String DepotName;
-
- private String AnotherDepotName;
-
- private Long UnitId;
-
- private String UName;
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public Long getHeaderid() {
- return headerid;
- }
-
- public void setHeaderid(Long headerid) {
- this.headerid = headerid;
- }
-
- public Long getMaterialid() {
- return materialid;
- }
-
- public void setMaterialid(Long materialid) {
- this.materialid = materialid;
- }
-
- public String getMunit() {
- return munit;
- }
-
- public void setMunit(String munit) {
- this.munit = munit;
- }
-
- public Double getOpernumber() {
- return opernumber;
- }
-
- public void setOpernumber(Double opernumber) {
- this.opernumber = opernumber;
- }
-
- public Double getBasicnumber() {
- return basicnumber;
- }
-
- public void setBasicnumber(Double basicnumber) {
- this.basicnumber = basicnumber;
- }
-
- public Double getUnitprice() {
- return unitprice;
- }
-
- public void setUnitprice(Double unitprice) {
- this.unitprice = unitprice;
- }
-
- public Double getTaxunitprice() {
- return taxunitprice;
- }
-
- public void setTaxunitprice(Double taxunitprice) {
- this.taxunitprice = taxunitprice;
- }
-
- public Double getAllprice() {
- return allprice;
- }
-
- public void setAllprice(Double allprice) {
- this.allprice = allprice;
- }
-
- public String getRemark() {
- return remark;
- }
-
- public void setRemark(String remark) {
- this.remark = remark;
- }
-
- public String getImg() {
- return img;
- }
-
- public void setImg(String img) {
- this.img = img;
- }
-
- public Double getIncidentals() {
- return incidentals;
- }
-
- public void setIncidentals(Double incidentals) {
- this.incidentals = incidentals;
- }
-
- public Long getDepotid() {
- return depotid;
- }
-
- public void setDepotid(Long depotid) {
- this.depotid = depotid;
- }
-
- public Long getAnotherdepotid() {
- return anotherdepotid;
- }
-
- public void setAnotherdepotid(Long anotherdepotid) {
- this.anotherdepotid = anotherdepotid;
- }
-
- public Double getTaxrate() {
- return taxrate;
- }
-
- public void setTaxrate(Double taxrate) {
- this.taxrate = taxrate;
- }
-
- public Double getTaxmoney() {
- return taxmoney;
- }
-
- public void setTaxmoney(Double taxmoney) {
- this.taxmoney = taxmoney;
- }
-
- public Double getTaxlastmoney() {
- return taxlastmoney;
- }
-
- public void setTaxlastmoney(Double taxlastmoney) {
- this.taxlastmoney = taxlastmoney;
- }
-
- public String getOtherfield1() {
- return otherfield1;
- }
-
- public void setOtherfield1(String otherfield1) {
- this.otherfield1 = otherfield1;
- }
-
- public String getOtherfield2() {
- return otherfield2;
- }
-
- public void setOtherfield2(String otherfield2) {
- this.otherfield2 = otherfield2;
- }
-
- public String getOtherfield3() {
- return otherfield3;
- }
-
- public void setOtherfield3(String otherfield3) {
- this.otherfield3 = otherfield3;
- }
-
- public String getOtherfield4() {
- return otherfield4;
- }
-
- public void setOtherfield4(String otherfield4) {
- this.otherfield4 = otherfield4;
- }
-
- public String getOtherfield5() {
- return otherfield5;
- }
-
- public void setOtherfield5(String otherfield5) {
- this.otherfield5 = otherfield5;
- }
-
- public String getMtype() {
- return mtype;
- }
-
- public void setMtype(String mtype) {
- this.mtype = mtype;
- }
-
- public String getMName() {
- return MName;
- }
-
- public void setMName(String MName) {
- this.MName = MName;
- }
-
- public String getMModel() {
- return MModel;
- }
-
- public void setMModel(String MModel) {
- this.MModel = MModel;
- }
-
- public String getMaterialUnit() {
- return MaterialUnit;
- }
-
- public void setMaterialUnit(String materialUnit) {
- MaterialUnit = materialUnit;
- }
-
- public String getMColor() {
- return MColor;
- }
-
- public void setMColor(String MColor) {
- this.MColor = MColor;
- }
-
- public String getMStandard() {
- return MStandard;
- }
-
- public void setMStandard(String MStandard) {
- this.MStandard = MStandard;
- }
-
- public String getMMfrs() {
- return MMfrs;
- }
-
- public void setMMfrs(String MMfrs) {
- this.MMfrs = MMfrs;
- }
-
- public String getMOtherField1() {
- return MOtherField1;
- }
-
- public void setMOtherField1(String MOtherField1) {
- this.MOtherField1 = MOtherField1;
- }
-
- public String getMOtherField2() {
- return MOtherField2;
- }
-
- public void setMOtherField2(String MOtherField2) {
- this.MOtherField2 = MOtherField2;
- }
-
- public String getMOtherField3() {
- return MOtherField3;
- }
-
- public void setMOtherField3(String MOtherField3) {
- this.MOtherField3 = MOtherField3;
- }
-
- public String getDepotName() {
- return DepotName;
- }
-
- public void setDepotName(String depotName) {
- DepotName = depotName;
- }
-
- public String getAnotherDepotName() {
- return AnotherDepotName;
- }
-
- public void setAnotherDepotName(String anotherDepotName) {
- AnotherDepotName = anotherDepotName;
- }
-
- public Long getUnitId() {
- return UnitId;
- }
-
- public void setUnitId(Long unitId) {
- UnitId = unitId;
- }
-
- public String getUName() {
- return UName;
- }
-
- public void setUName(String UName) {
- this.UName = UName;
- }
+package com.jsh.erp.datasource.entities;
+
+public class DepotItemVo4WithInfoEx {
+
+ private Long id;
+
+ private Long headerid;
+
+ private Long materialid;
+
+ private String munit;
+
+ private Double opernumber;
+
+ private Double basicnumber;
+
+ private Double unitprice;
+
+ private Double taxunitprice;
+
+ private Double allprice;
+
+ private String remark;
+
+ private String img;
+
+ private Double incidentals;
+
+ private Long depotid;
+
+ private Long anotherdepotid;
+
+ private Double taxrate;
+
+ private Double taxmoney;
+
+ private Double taxlastmoney;
+
+ private String otherfield1;
+
+ private String otherfield2;
+
+ private String otherfield3;
+
+ private String otherfield4;
+
+ private String otherfield5;
+
+ private String mtype;
+
+ private Long MId;
+
+ private String MName;
+
+ private String MModel;
+
+ private String MaterialUnit;
+
+ private String MColor;
+
+ private String MStandard;
+
+ private String MMfrs;
+
+ private String MOtherField1;
+
+ private String MOtherField2;
+
+ private String MOtherField3;
+
+ private String DepotName;
+
+ private String AnotherDepotName;
+
+ private Long UnitId;
+
+ private String UName;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Long getHeaderid() {
+ return headerid;
+ }
+
+ public void setHeaderid(Long headerid) {
+ this.headerid = headerid;
+ }
+
+ public Long getMaterialid() {
+ return materialid;
+ }
+
+ public void setMaterialid(Long materialid) {
+ this.materialid = materialid;
+ }
+
+ public String getMunit() {
+ return munit;
+ }
+
+ public void setMunit(String munit) {
+ this.munit = munit;
+ }
+
+ public Double getOpernumber() {
+ return opernumber;
+ }
+
+ public void setOpernumber(Double opernumber) {
+ this.opernumber = opernumber;
+ }
+
+ public Double getBasicnumber() {
+ return basicnumber;
+ }
+
+ public void setBasicnumber(Double basicnumber) {
+ this.basicnumber = basicnumber;
+ }
+
+ public Double getUnitprice() {
+ return unitprice;
+ }
+
+ public void setUnitprice(Double unitprice) {
+ this.unitprice = unitprice;
+ }
+
+ public Double getTaxunitprice() {
+ return taxunitprice;
+ }
+
+ public void setTaxunitprice(Double taxunitprice) {
+ this.taxunitprice = taxunitprice;
+ }
+
+ public Double getAllprice() {
+ return allprice;
+ }
+
+ public void setAllprice(Double allprice) {
+ this.allprice = allprice;
+ }
+
+ public String getRemark() {
+ return remark;
+ }
+
+ public void setRemark(String remark) {
+ this.remark = remark;
+ }
+
+ public String getImg() {
+ return img;
+ }
+
+ public void setImg(String img) {
+ this.img = img;
+ }
+
+ public Double getIncidentals() {
+ return incidentals;
+ }
+
+ public void setIncidentals(Double incidentals) {
+ this.incidentals = incidentals;
+ }
+
+ public Long getDepotid() {
+ return depotid;
+ }
+
+ public void setDepotid(Long depotid) {
+ this.depotid = depotid;
+ }
+
+ public Long getAnotherdepotid() {
+ return anotherdepotid;
+ }
+
+ public void setAnotherdepotid(Long anotherdepotid) {
+ this.anotherdepotid = anotherdepotid;
+ }
+
+ public Double getTaxrate() {
+ return taxrate;
+ }
+
+ public void setTaxrate(Double taxrate) {
+ this.taxrate = taxrate;
+ }
+
+ public Double getTaxmoney() {
+ return taxmoney;
+ }
+
+ public void setTaxmoney(Double taxmoney) {
+ this.taxmoney = taxmoney;
+ }
+
+ public Double getTaxlastmoney() {
+ return taxlastmoney;
+ }
+
+ public void setTaxlastmoney(Double taxlastmoney) {
+ this.taxlastmoney = taxlastmoney;
+ }
+
+ public String getOtherfield1() {
+ return otherfield1;
+ }
+
+ public void setOtherfield1(String otherfield1) {
+ this.otherfield1 = otherfield1;
+ }
+
+ public String getOtherfield2() {
+ return otherfield2;
+ }
+
+ public void setOtherfield2(String otherfield2) {
+ this.otherfield2 = otherfield2;
+ }
+
+ public String getOtherfield3() {
+ return otherfield3;
+ }
+
+ public void setOtherfield3(String otherfield3) {
+ this.otherfield3 = otherfield3;
+ }
+
+ public String getOtherfield4() {
+ return otherfield4;
+ }
+
+ public void setOtherfield4(String otherfield4) {
+ this.otherfield4 = otherfield4;
+ }
+
+ public String getOtherfield5() {
+ return otherfield5;
+ }
+
+ public void setOtherfield5(String otherfield5) {
+ this.otherfield5 = otherfield5;
+ }
+
+ public String getMtype() {
+ return mtype;
+ }
+
+ public void setMtype(String mtype) {
+ this.mtype = mtype;
+ }
+
+ public Long getMId() {
+ return MId;
+ }
+
+ public void setMId(Long MId) {
+ this.MId = MId;
+ }
+
+ public String getMName() {
+ return MName;
+ }
+
+ public void setMName(String MName) {
+ this.MName = MName;
+ }
+
+ public String getMModel() {
+ return MModel;
+ }
+
+ public void setMModel(String MModel) {
+ this.MModel = MModel;
+ }
+
+ public String getMaterialUnit() {
+ return MaterialUnit;
+ }
+
+ public void setMaterialUnit(String materialUnit) {
+ MaterialUnit = materialUnit;
+ }
+
+ public String getMColor() {
+ return MColor;
+ }
+
+ public void setMColor(String MColor) {
+ this.MColor = MColor;
+ }
+
+ public String getMStandard() {
+ return MStandard;
+ }
+
+ public void setMStandard(String MStandard) {
+ this.MStandard = MStandard;
+ }
+
+ public String getMMfrs() {
+ return MMfrs;
+ }
+
+ public void setMMfrs(String MMfrs) {
+ this.MMfrs = MMfrs;
+ }
+
+ public String getMOtherField1() {
+ return MOtherField1;
+ }
+
+ public void setMOtherField1(String MOtherField1) {
+ this.MOtherField1 = MOtherField1;
+ }
+
+ public String getMOtherField2() {
+ return MOtherField2;
+ }
+
+ public void setMOtherField2(String MOtherField2) {
+ this.MOtherField2 = MOtherField2;
+ }
+
+ public String getMOtherField3() {
+ return MOtherField3;
+ }
+
+ public void setMOtherField3(String MOtherField3) {
+ this.MOtherField3 = MOtherField3;
+ }
+
+ public String getDepotName() {
+ return DepotName;
+ }
+
+ public void setDepotName(String depotName) {
+ DepotName = depotName;
+ }
+
+ public String getAnotherDepotName() {
+ return AnotherDepotName;
+ }
+
+ public void setAnotherDepotName(String anotherDepotName) {
+ AnotherDepotName = anotherDepotName;
+ }
+
+ public Long getUnitId() {
+ return UnitId;
+ }
+
+ public void setUnitId(Long unitId) {
+ UnitId = unitId;
+ }
+
+ public String getUName() {
+ return UName;
+ }
+
+ public void setUName(String UName) {
+ this.UName = UName;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/jsh/erp/datasource/mappers/MaterialMapper.java b/src/main/java/com/jsh/erp/datasource/mappers/MaterialMapper.java
index d89547c8..e2097309 100644
--- a/src/main/java/com/jsh/erp/datasource/mappers/MaterialMapper.java
+++ b/src/main/java/com/jsh/erp/datasource/mappers/MaterialMapper.java
@@ -1,124 +1,130 @@
-package com.jsh.erp.datasource.mappers;
-
-import com.jsh.erp.datasource.entities.Material;
-import com.jsh.erp.datasource.entities.MaterialExample;
-import java.util.List;
-
-import com.jsh.erp.datasource.entities.MaterialVo4Unit;
-import org.apache.ibatis.annotations.Param;
-
-public interface MaterialMapper {
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_material
- *
- * @mbggenerated
- */
- int countByExample(MaterialExample example);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_material
- *
- * @mbggenerated
- */
- int deleteByExample(MaterialExample example);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_material
- *
- * @mbggenerated
- */
- int deleteByPrimaryKey(Long id);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_material
- *
- * @mbggenerated
- */
- int insert(Material record);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_material
- *
- * @mbggenerated
- */
- int insertSelective(Material record);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_material
- *
- * @mbggenerated
- */
- List selectByExample(MaterialExample example);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_material
- *
- * @mbggenerated
- */
- Material selectByPrimaryKey(Long id);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_material
- *
- * @mbggenerated
- */
- int updateByExampleSelective(@Param("record") Material record, @Param("example") MaterialExample example);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_material
- *
- * @mbggenerated
- */
- int updateByExample(@Param("record") Material record, @Param("example") MaterialExample example);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_material
- *
- * @mbggenerated
- */
- int updateByPrimaryKeySelective(Material record);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_material
- *
- * @mbggenerated
- */
- int updateByPrimaryKey(Material record);
-
- List selectByConditionMaterial(
- @Param("name") String name,
- @Param("model") String model,
- @Param("categoryId") Long categoryId,
- @Param("categoryIds") String categoryIds,
- @Param("mpList") String mpList,
- @Param("offset") Integer offset,
- @Param("rows") Integer rows);
-
- int countsByMaterial(
- @Param("name") String name,
- @Param("model") String model,
- @Param("categoryId") Long categoryId,
- @Param("categoryIds") String categoryIds,
- @Param("mpList") String mpList);
-
- String findUnitName(@Param("mId") Long mId);
-
- List findById(@Param("id") Long id);
-
- List findBySelect();
-
- int updatePriceNullByPrimaryKey(Long id);
-
- int updateUnitIdNullByPrimaryKey(Long id);
+package com.jsh.erp.datasource.mappers;
+
+import com.jsh.erp.datasource.entities.Material;
+import com.jsh.erp.datasource.entities.MaterialExample;
+import java.util.List;
+
+import com.jsh.erp.datasource.entities.MaterialVo4Unit;
+import org.apache.ibatis.annotations.Param;
+
+public interface MaterialMapper {
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_material
+ *
+ * @mbggenerated
+ */
+ int countByExample(MaterialExample example);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_material
+ *
+ * @mbggenerated
+ */
+ int deleteByExample(MaterialExample example);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_material
+ *
+ * @mbggenerated
+ */
+ int deleteByPrimaryKey(Long id);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_material
+ *
+ * @mbggenerated
+ */
+ int insert(Material record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_material
+ *
+ * @mbggenerated
+ */
+ int insertSelective(Material record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_material
+ *
+ * @mbggenerated
+ */
+ List selectByExample(MaterialExample example);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_material
+ *
+ * @mbggenerated
+ */
+ Material selectByPrimaryKey(Long id);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_material
+ *
+ * @mbggenerated
+ */
+ int updateByExampleSelective(@Param("record") Material record, @Param("example") MaterialExample example);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_material
+ *
+ * @mbggenerated
+ */
+ int updateByExample(@Param("record") Material record, @Param("example") MaterialExample example);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_material
+ *
+ * @mbggenerated
+ */
+ int updateByPrimaryKeySelective(Material record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_material
+ *
+ * @mbggenerated
+ */
+ int updateByPrimaryKey(Material record);
+
+ List selectByConditionMaterial(
+ @Param("name") String name,
+ @Param("model") String model,
+ @Param("categoryId") Long categoryId,
+ @Param("categoryIds") String categoryIds,
+ @Param("mpList") String mpList,
+ @Param("offset") Integer offset,
+ @Param("rows") Integer rows);
+
+ int countsByMaterial(
+ @Param("name") String name,
+ @Param("model") String model,
+ @Param("categoryId") Long categoryId,
+ @Param("categoryIds") String categoryIds,
+ @Param("mpList") String mpList);
+
+ String findUnitName(@Param("mId") Long mId);
+
+ List findById(@Param("id") Long id);
+
+ List findBySelect();
+
+ int updatePriceNullByPrimaryKey(Long id);
+
+ int updateUnitIdNullByPrimaryKey(Long id);
+
+ List findByAll(
+ @Param("name") String name,
+ @Param("model") String model,
+ @Param("categoryId") Long categoryId,
+ @Param("categoryIds") String categoryIds);
}
\ No newline at end of file
diff --git a/src/main/java/com/jsh/erp/datasource/mappers/SupplierMapper.java b/src/main/java/com/jsh/erp/datasource/mappers/SupplierMapper.java
index d06df131..5d0f2fb5 100644
--- a/src/main/java/com/jsh/erp/datasource/mappers/SupplierMapper.java
+++ b/src/main/java/com/jsh/erp/datasource/mappers/SupplierMapper.java
@@ -1,112 +1,119 @@
-package com.jsh.erp.datasource.mappers;
-
-import com.jsh.erp.datasource.entities.Supplier;
-import com.jsh.erp.datasource.entities.SupplierExample;
-import java.util.List;
-import org.apache.ibatis.annotations.Param;
-
-public interface SupplierMapper {
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_supplier
- *
- * @mbggenerated
- */
- int countByExample(SupplierExample example);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_supplier
- *
- * @mbggenerated
- */
- int deleteByExample(SupplierExample example);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_supplier
- *
- * @mbggenerated
- */
- int deleteByPrimaryKey(Long id);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_supplier
- *
- * @mbggenerated
- */
- int insert(Supplier record);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_supplier
- *
- * @mbggenerated
- */
- int insertSelective(Supplier record);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_supplier
- *
- * @mbggenerated
- */
- List selectByExample(SupplierExample example);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_supplier
- *
- * @mbggenerated
- */
- Supplier selectByPrimaryKey(Long id);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_supplier
- *
- * @mbggenerated
- */
- int updateByExampleSelective(@Param("record") Supplier record, @Param("example") SupplierExample example);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_supplier
- *
- * @mbggenerated
- */
- int updateByExample(@Param("record") Supplier record, @Param("example") SupplierExample example);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_supplier
- *
- * @mbggenerated
- */
- int updateByPrimaryKeySelective(Supplier record);
-
- /**
- * This method was generated by MyBatis Generator.
- * This method corresponds to the database table jsh_supplier
- *
- * @mbggenerated
- */
- int updateByPrimaryKey(Supplier record);
-
- List selectByConditionSupplier(
- @Param("supplier") String supplier,
- @Param("type") String type,
- @Param("phonenum") String phonenum,
- @Param("telephone") String telephone,
- @Param("description") String description,
- @Param("offset") Integer offset,
- @Param("rows") Integer rows);
-
- int countsBySupplier(
- @Param("supplier") String supplier,
- @Param("type") String type,
- @Param("phonenum") String phonenum,
- @Param("telephone") String telephone,
- @Param("description") String description);
+package com.jsh.erp.datasource.mappers;
+
+import com.jsh.erp.datasource.entities.Supplier;
+import com.jsh.erp.datasource.entities.SupplierExample;
+import java.util.List;
+import org.apache.ibatis.annotations.Param;
+
+public interface SupplierMapper {
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_supplier
+ *
+ * @mbggenerated
+ */
+ int countByExample(SupplierExample example);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_supplier
+ *
+ * @mbggenerated
+ */
+ int deleteByExample(SupplierExample example);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_supplier
+ *
+ * @mbggenerated
+ */
+ int deleteByPrimaryKey(Long id);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_supplier
+ *
+ * @mbggenerated
+ */
+ int insert(Supplier record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_supplier
+ *
+ * @mbggenerated
+ */
+ int insertSelective(Supplier record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_supplier
+ *
+ * @mbggenerated
+ */
+ List selectByExample(SupplierExample example);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_supplier
+ *
+ * @mbggenerated
+ */
+ Supplier selectByPrimaryKey(Long id);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_supplier
+ *
+ * @mbggenerated
+ */
+ int updateByExampleSelective(@Param("record") Supplier record, @Param("example") SupplierExample example);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_supplier
+ *
+ * @mbggenerated
+ */
+ int updateByExample(@Param("record") Supplier record, @Param("example") SupplierExample example);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_supplier
+ *
+ * @mbggenerated
+ */
+ int updateByPrimaryKeySelective(Supplier record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table jsh_supplier
+ *
+ * @mbggenerated
+ */
+ int updateByPrimaryKey(Supplier record);
+
+ List selectByConditionSupplier(
+ @Param("supplier") String supplier,
+ @Param("type") String type,
+ @Param("phonenum") String phonenum,
+ @Param("telephone") String telephone,
+ @Param("description") String description,
+ @Param("offset") Integer offset,
+ @Param("rows") Integer rows);
+
+ int countsBySupplier(
+ @Param("supplier") String supplier,
+ @Param("type") String type,
+ @Param("phonenum") String phonenum,
+ @Param("telephone") String telephone,
+ @Param("description") String description);
+
+ List findByAll(
+ @Param("supplier") String supplier,
+ @Param("type") String type,
+ @Param("phonenum") String phonenum,
+ @Param("telephone") String telephone,
+ @Param("description") String description);
}
\ No newline at end of file
diff --git a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java
index 768bc8d0..95714ef0 100644
--- a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java
+++ b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java
@@ -84,14 +84,18 @@ public class DepotHeadService {
}
depotHead.setCreatetime(new Timestamp(System.currentTimeMillis()));
depotHead.setStatus(false);
- return depotHeadMapper.insertSelective(depotHead);
+ return depotHeadMapper.insert(depotHead);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateDepotHead(String beanJson, Long id) {
+ DepotHead dh = depotHeadMapper.selectByPrimaryKey(id);
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
depotHead.setId(id);
- return depotHeadMapper.updateByPrimaryKeySelective(depotHead);
+ depotHead.setStatus(dh.getStatus());
+ depotHead.setCreatetime(dh.getCreatetime());
+ depotHead.setOperpersonname(dh.getOperpersonname());
+ return depotHeadMapper.updateByPrimaryKey(depotHead);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
diff --git a/src/main/java/com/jsh/erp/service/material/MaterialService.java b/src/main/java/com/jsh/erp/service/material/MaterialService.java
index 2e8a7b4a..45c8f4b8 100644
--- a/src/main/java/com/jsh/erp/service/material/MaterialService.java
+++ b/src/main/java/com/jsh/erp/service/material/MaterialService.java
@@ -5,6 +5,7 @@ import com.jsh.erp.datasource.entities.Material;
import com.jsh.erp.datasource.entities.MaterialExample;
import com.jsh.erp.datasource.entities.MaterialVo4Unit;
import com.jsh.erp.datasource.mappers.MaterialMapper;
+import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -14,7 +15,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
@Service
public class MaterialService {
@@ -160,4 +163,32 @@ public class MaterialService {
return materialMapper.selectByExample(example);
}
+ public List findByAll(String name, String model, Long categoryId, String categoryIds) {
+ List resList = new ArrayList();
+ List list = materialMapper.findByAll(name, model, categoryId, categoryIds);
+ if (null != list) {
+ for (MaterialVo4Unit m : list) {
+ resList.add(m);
+ }
+ }
+ return resList;
+ }
+
+ public BaseResponseInfo importExcel(List mList) throws Exception {
+ BaseResponseInfo info = new BaseResponseInfo();
+ Map data = new HashMap();
+ try {
+ for(Material m: mList) {
+ materialMapper.insertSelective(m);
+ }
+ info.code = 200;
+ data.put("message", "成功");
+ } catch (Exception e) {
+ e.printStackTrace();
+ info.code = 500;
+ data.put("message", e.getMessage());
+ }
+ info.data = data;
+ return info;
+ }
}
diff --git a/src/main/java/com/jsh/erp/service/supplier/SupplierService.java b/src/main/java/com/jsh/erp/service/supplier/SupplierService.java
index 5074eb6b..9517a9c5 100644
--- a/src/main/java/com/jsh/erp/service/supplier/SupplierService.java
+++ b/src/main/java/com/jsh/erp/service/supplier/SupplierService.java
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Supplier;
import com.jsh.erp.datasource.entities.SupplierExample;
import com.jsh.erp.datasource.mappers.SupplierMapper;
+import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -12,7 +13,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
@Service
public class SupplierService {
@@ -123,4 +126,26 @@ public class SupplierService {
List list = supplierMapper.selectByExample(example);
return list;
}
+
+ public List findByAll(String supplier, String type, String phonenum, String telephone, String description) {
+ return supplierMapper.findByAll(supplier, type, phonenum, telephone, description);
+ }
+
+ public BaseResponseInfo importExcel(List mList) throws Exception {
+ BaseResponseInfo info = new BaseResponseInfo();
+ Map data = new HashMap();
+ try {
+ for(Supplier s: mList) {
+ supplierMapper.insertSelective(s);
+ }
+ info.code = 200;
+ data.put("message", "成功");
+ } catch (Exception e) {
+ e.printStackTrace();
+ info.code = 500;
+ data.put("message", e.getMessage());
+ }
+ info.data = data;
+ return info;
+ }
}
diff --git a/src/main/java/com/jsh/erp/utils/ExcelUtils.java b/src/main/java/com/jsh/erp/utils/ExcelUtils.java
new file mode 100644
index 00000000..a72362b6
--- /dev/null
+++ b/src/main/java/com/jsh/erp/utils/ExcelUtils.java
@@ -0,0 +1,240 @@
+package com.jsh.erp.utils;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.alibaba.druid.util.StringUtils;
+import jxl.Cell;
+import jxl.Sheet;
+import jxl.Workbook;
+import jxl.format.*;
+import jxl.write.Label;
+import jxl.write.WritableCellFormat;
+import jxl.write.WritableFont;
+import jxl.write.WritableSheet;
+import jxl.write.WritableWorkbook;
+
+public class ExcelUtils {
+
+ public static WritableFont arial14font = null;
+
+ public static File exportObjects(String fileName, String[] names,
+ String title, List objects) throws Exception {
+ File excelFile = new File("fileName.xls");
+ WritableWorkbook wtwb = Workbook.createWorkbook(excelFile);
+ WritableSheet sheet = wtwb.createSheet(title, 0);
+ sheet.getSettings().setDefaultColumnWidth(20);
+ WritableFont wfont = new WritableFont(WritableFont.createFont("楷书"), 15);
+ WritableCellFormat format = new WritableCellFormat(wfont);
+ WritableFont wfc = new WritableFont(WritableFont.ARIAL, 20,
+ WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,
+ jxl.format.Colour.BLACK);
+ WritableCellFormat wcfFC = new WritableCellFormat(wfc);
+ wcfFC.setAlignment(Alignment.CENTRE);
+ wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);
+ // CellView cellView = new CellView();
+ // cellView.setAutosize(true); //设置自动大小
+ format.setAlignment(Alignment.LEFT);
+ format.setVerticalAlignment(VerticalAlignment.TOP);
+ sheet.mergeCells(0, 0, names.length - 1, 0);
+ sheet.addCell(new Label(0, 0, title, wcfFC));
+ int rowNum = 2;
+ for (int i = 0; i < names.length; i++) {
+ sheet.addCell(new Label(i, 1, names[i], format));
+ }
+ for (int j = 0; j < objects.size(); j++) {
+ String[] obj = objects.get(j);
+ for (int h = 0; h < obj.length; h++) {
+ sheet.addCell(new Label(h, rowNum, obj[h], format));
+ }
+ rowNum = rowNum + 1;
+
+ }
+ wtwb.write();
+ wtwb.close();
+ return excelFile;
+ }
+
+ /**
+ * 导出excel,不需要第一行的title
+ *
+ * @param fileName
+ * @param names
+ * @param title
+ * @param objects
+ * @return
+ * @throws Exception
+ */
+ public static File exportObjectsWithoutTitle(String fileName,
+ String[] names, String title, List objects)
+ throws Exception {
+ File excelFile = new File(fileName);
+ WritableWorkbook wtwb = Workbook.createWorkbook(excelFile);
+ WritableSheet sheet = wtwb.createSheet(title, 0);
+ sheet.getSettings().setDefaultColumnWidth(20);
+
+ // 第一行的格式
+ WritableFont wfc = new WritableFont(WritableFont.ARIAL, 15,
+ WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,
+ jxl.format.Colour.BLACK);
+ WritableCellFormat wcfFC = new WritableCellFormat(wfc);
+ wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);
+
+ // 设置字体以及单元格格式
+ WritableFont wfont = new WritableFont(WritableFont.createFont("楷书"), 15);
+ WritableCellFormat format = new WritableCellFormat(wfont);
+ format.setAlignment(Alignment.LEFT);
+ format.setVerticalAlignment(VerticalAlignment.TOP);
+
+ // 第一行写入标题
+ for (int i = 0; i < names.length; i++) {
+ sheet.addCell(new Label(i, 0, names[i], wcfFC));
+ }
+
+ // 其余行依次写入数据
+ int rowNum = 1;
+ for (int j = 0; j < objects.size(); j++) {
+ String[] obj = objects.get(j);
+ for (int h = 0; h < obj.length; h++) {
+ sheet.addCell(new Label(h, rowNum, obj[h], format));
+ }
+ rowNum = rowNum + 1;
+ }
+ wtwb.write();
+ wtwb.close();
+ return excelFile;
+ }
+
+ public static String createTempFile(String[] names, String title, List objects) throws Exception {
+ File excelFile = File.createTempFile(System.currentTimeMillis() + "", ".xls");
+ WritableWorkbook wtwb = Workbook.createWorkbook(excelFile);
+ WritableSheet sheet = wtwb.createSheet(title, 0);
+ sheet.getSettings().setDefaultColumnWidth(20);
+ WritableFont wfont = new WritableFont(WritableFont.createFont("楷书"), 15);
+ WritableCellFormat format = new WritableCellFormat(wfont);
+ WritableFont wfc = new WritableFont(WritableFont.ARIAL, 20,
+ WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,
+ jxl.format.Colour.BLACK);
+ WritableCellFormat wcfFC = new WritableCellFormat(wfc);
+ wcfFC.setAlignment(Alignment.CENTRE);
+ wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);
+ // CellView cellView = new CellView();
+ // cellView.setAutosize(true); //设置自动大小
+ format.setAlignment(Alignment.LEFT);
+ format.setVerticalAlignment(VerticalAlignment.TOP);
+ sheet.mergeCells(0, 0, names.length - 1, 0);
+ sheet.addCell(new Label(0, 0, title, wcfFC));
+ int rowNum = 2;
+ for (int i = 0; i < names.length; i++) {
+ sheet.addCell(new Label(i, 1, names[i], format));
+ }
+ for (int j = 0; j < objects.size(); j++) {
+ String[] obj = objects.get(j);
+ for (int h = 0; h < obj.length; h++) {
+ sheet.addCell(new Label(h, rowNum, obj[h], format));
+ }
+ rowNum = rowNum + 1;
+ }
+ wtwb.write();
+ wtwb.close();
+ return excelFile.getName();
+ }
+
+ public static String createCheckRandomTempFile(String[] names, String title, List objects,Map infoMap) throws Exception {
+ File excelFile = File.createTempFile(System.currentTimeMillis() + "", ".xls");
+ WritableWorkbook wtwb = Workbook.createWorkbook(excelFile);
+ WritableSheet sheet = wtwb.createSheet(title, 0);
+ sheet.getSettings().setDefaultColumnWidth(20);
+ WritableFont wfont = new WritableFont(WritableFont.createFont("楷书"), 14);
+
+ WritableCellFormat format = new WritableCellFormat(wfont);
+ format.setBorder(Border.ALL, BorderLineStyle.THIN);
+ format.setAlignment(Alignment.CENTRE);
+ format.setVerticalAlignment(VerticalAlignment.CENTRE);
+
+ WritableFont wfc = new WritableFont(WritableFont.ARIAL, 20,
+ WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,
+ jxl.format.Colour.BLACK);
+ WritableCellFormat wcfFC = new WritableCellFormat(wfc);
+ wcfFC.setAlignment(Alignment.LEFT);
+ wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);
+
+ WritableFont nameWfc = new WritableFont(WritableFont.ARIAL, 14,
+ WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,
+ jxl.format.Colour.BLACK);
+ WritableCellFormat nameFormat = new WritableCellFormat(nameWfc);
+ nameFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
+ nameFormat.setAlignment(Alignment.CENTRE);
+ nameFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
+
+ WritableCellFormat infoFormat = new WritableCellFormat(wfont);
+ infoFormat.setAlignment(Alignment.LEFT);
+ infoFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
+
+
+ sheet.mergeCells(0, 0, names.length - 1, 0);
+ sheet.addCell(new Label(0, 0, infoMap.get("title"), wcfFC));
+
+ sheet.addCell(new Label(0, 2, infoMap.get("info"), infoFormat));
+ sheet.addCell(new Label(2, 2, infoMap.get("dvrnvr"), infoFormat));
+ sheet.addCell(new Label(4, 2, infoMap.get("char"), infoFormat));
+ sheet.addCell(new Label(0, 3, infoMap.get("infoPercent"), infoFormat));
+ sheet.addCell(new Label(2, 3, infoMap.get("dvrnvrPercent"), infoFormat));
+ sheet.addCell(new Label(4, 3, infoMap.get("charPercent"), infoFormat));
+
+ int rowNum = 5;
+ for (int i = 0; i < names.length; i++) {
+ sheet.addCell(new Label(i, 4, names[i], nameFormat));
+ }
+ for (int j = 0; j < objects.size(); j++) {
+ String[] obj = objects.get(j);
+ for (int h = 0; h < obj.length; h++) {
+ sheet.addCell(new Label(h, rowNum, obj[h], format));
+ }
+ rowNum = rowNum + 1;
+ }
+ wtwb.write();
+ wtwb.close();
+ return excelFile.getName();
+ }
+
+
+
+ public static String getContent(Sheet src, int rowNum, int colNum) {
+ return src.getRow(rowNum)[colNum].getContents().trim();
+ }
+
+ /**
+ * 从第i行开始到最后检测指定列的唯一性
+ *
+ * @param src
+ * @param colNum
+ * @param fromRow
+ * 起始行
+ * @return
+ */
+ public static Boolean checkUnique(Sheet src, int colNum, int fromRow) {
+ Cell[] colCells = src.getColumn(colNum);
+ Set set = new HashSet();
+ for (int i = fromRow; i < colCells.length; i++) {
+ if (!StringUtils.isEmpty(colCells[i].getContents())
+ && !set.add(colCells[i].getContents())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static File getTempFile(String fileName) {
+ String dir = System.getProperty("java.io.tmpdir"); // 获取系统临时目录
+ return new File(dir + File.separator + fileName);
+ }
+
+ public static void main(String[] args) throws Exception {
+ String msg = "12345";
+ System.out.println(msg.indexOf("@"));
+ }
+}
diff --git a/src/main/java/com/jsh/erp/utils/ExportExecUtil.java b/src/main/java/com/jsh/erp/utils/ExportExecUtil.java
new file mode 100644
index 00000000..69aee9e3
--- /dev/null
+++ b/src/main/java/com/jsh/erp/utils/ExportExecUtil.java
@@ -0,0 +1,28 @@
+package com.jsh.erp.utils;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.OutputStream;
+
+public class ExportExecUtil {
+
+ public static void showExec(File excelFile,String fileName,HttpServletResponse response) throws Exception{
+ response.setContentType("application/octet-stream");
+ fileName = new String(fileName.getBytes("gbk"),"ISO8859_1");
+ response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + ".xls" + "\"");
+ FileInputStream fis = new FileInputStream(excelFile);
+ OutputStream out = response.getOutputStream();
+
+ int SIZE = 1024 * 1024;
+ byte[] bytes = new byte[SIZE];
+ int LENGTH = -1;
+ while((LENGTH = fis.read(bytes)) != -1){
+ out.write(bytes,0,LENGTH);
+ }
+
+ out.flush();
+ fis.close();
+ }
+
+}
diff --git a/src/main/java/com/jsh/erp/utils/FileUtils.java b/src/main/java/com/jsh/erp/utils/FileUtils.java
new file mode 100644
index 00000000..59a7b159
--- /dev/null
+++ b/src/main/java/com/jsh/erp/utils/FileUtils.java
@@ -0,0 +1,334 @@
+package com.jsh.erp.utils;
+
+import com.alibaba.druid.util.StringUtils;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ *
+ * 文件处理工具类
+ *
+ */
+public class FileUtils {
+
+ /**
+ * 功 能: 创建文件夹
+ *
+ * @param path
+ * 参 数:要创建的文件夹名称
+ * @return 返回值: 如果成功true;否则false 如:FileUtils.mkdir("/usr/apps/upload/");
+ */
+ public static boolean makedir(String path) {
+ File file = new File(path);
+ if (!file.exists())
+ return file.mkdirs();
+ else
+ return true;
+ }
+
+ /**
+ * 保存文件
+ *
+ * @param stream
+ * @param path
+ * 存放路径
+ * @param filename
+ * 文件名
+ * @throws IOException
+ */
+ public static void SaveFileFromInputStream(InputStream stream, String path, String filename)
+ throws IOException {
+ File file = new File(path);
+ boolean flag=true;
+ if(!file.exists()){
+ flag=file.mkdirs();
+ }
+ if(flag){
+ FileOutputStream fs = new FileOutputStream(new File(path+filename));
+ byte[] buffer = new byte[1024 * 1024];
+ int byteread = 0;
+ while ((byteread = stream.read(buffer)) != -1) {
+ fs.write(buffer, 0, byteread);
+ fs.flush();
+ }
+ fs.close();
+ stream.close();
+ }
+ }
+
+
+ /**
+ * 列出某个目录下的所有文件,子目录不列出
+ * @param folderPath:文件夹路径
+ * @return
+ */
+ public static List listFile(String folderPath){
+ List fileList = new ArrayList(); //FileViewer.getListFiles(destPath, null, false);
+ File f = new File(folderPath);
+ File[] t = f.listFiles();
+ for(int i = 0; i < t.length; i++){
+ fileList.add(t[i].getAbsolutePath());
+ }
+ return fileList;
+ }
+
+
+ /**
+ * 判断文件是否存在
+ *
+ * @param fileName
+ * @return
+ */
+ public static boolean exists(String fileName) {
+ File file = new File(fileName);
+ if (file.exists()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * 取当前路径
+ *
+ * @return
+ */
+ public static String getCurrentPath() {
+ File directory = new File(".");
+ String nowPath = "";
+ try {
+ nowPath = directory.getCanonicalFile().toString();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return nowPath;
+ }
+
+ /**
+ * 获取文件扩展名
+ *
+ * @param fileName
+ * @return
+ * */
+ public static String getFileExtendName(String fileName) {
+ if (fileName == null) {
+ return "";
+ } else {
+ return fileName.substring(fileName.lastIndexOf(".") + 1, fileName
+ .length());
+ }
+ }
+
+ /**
+ * 创建一个新文件,如果存在则报错
+ *
+ * @param filePath
+ * @param fileName
+ * @return
+ */
+ public static void createFile(String filePath, String fileName)
+ throws RuntimeException {
+ String file = null;
+ if (filePath == null) {
+ file = fileName;
+ } else {
+ file = filePath + File.separator + fileName;
+ }
+ createFile(file);
+ }
+
+ /**
+ * 创建一个新文件(含路径),如果存在则报错
+ *
+ * @param fileName
+ * 含有路径的文件名
+ * @return
+ */
+ public static void createFile(String fileName) throws RuntimeException {
+ File f = new File(fileName);
+ if (f.exists()) {
+ throw new RuntimeException("FILE_EXIST_ERROR");
+ } else {
+ try {
+ File fileFolder = f.getParentFile();
+ if (!fileFolder.exists())
+ fileFolder.mkdirs();
+ f.createNewFile();
+ } catch (IOException ie) {
+ System.out.println("文件" + fileName + "创建失败:" + ie.getMessage());
+ throw new RuntimeException("FILE_CREATE_ERROR");
+ }
+ }
+ }
+
+
+ /**
+ * 创建目录,如果存在则不创建
+ *
+ * @param path
+ * @return 返回结果null则创建成功,否则返回的是错误信息
+ * @return
+ */
+ public static String createDir(String path, boolean isCreateSubPah) {
+ String msg = null;
+ File dir = new File(path);
+
+ if (dir == null) {
+ msg = "不能创建空目录";
+ return msg;
+ }
+ if (dir.isFile()) {
+ msg = "已有同名文件存在";
+ return msg;
+ }
+ if (!dir.exists()) {
+ if (isCreateSubPah && !dir.mkdirs()) {
+ msg = "目录创建失败,原因不明";
+ } else if (!dir.mkdir()) {
+ msg = "目录创建失败,原因不明";
+ }
+ }
+ return msg;
+ }
+
+ /**
+ * 删除指定目录或文件。 如果要删除是目录,同时删除子目录下所有的文件
+ *
+ * @file:File 目录
+ * */
+ public static void delFileOrFolder(String fileName) {
+ if (!exists(fileName))
+ return;
+ File file = new File(fileName);
+ delFileOrFolder(file);
+ }
+
+ /**
+ * 删除指定目录或文件。 如果要删除是目录,同时删除子目录下所有的文件
+ *
+ * @file:File 目录
+ * */
+ public static void delFileOrFolder(File file) {
+ if (!file.exists())
+ return;
+ if (file.isFile()) {
+ file.delete();
+ } else {
+ File[] sub = file.listFiles();
+ if (sub == null || sub.length <= 0) {
+ file.delete();
+ } else {
+ for (int i = 0; i < sub.length; i++) {
+ delFileOrFolder(sub[i]);
+ }
+ file.delete();
+ }
+ }
+ }
+
+ /**
+ * 从Properties格式配置文件中获取所有参数并保存到HashMap中。
+ * 配置中的key值即map表中的key值,如果配置文件保存时用的中文,则返回结果也会转成中文。
+ *
+ * @param file
+ * @return
+ * @throws IOException
+ */
+ @SuppressWarnings("unchecked")
+ public static HashMap readPropertyFile(String file, String charsetName) throws IOException {
+ if (charsetName==null || charsetName.trim().length()==0){
+ charsetName="gbk";
+ }
+ HashMap map = new HashMap();
+ InputStream is =null;
+ if(file.startsWith("file:"))
+ is=new FileInputStream(new File(file.substring(5)));
+ else
+ is=FileUtils.class.getClassLoader().getResourceAsStream(file);
+ Properties properties = new Properties();
+ properties.load(is);
+ Enumeration en = properties.propertyNames();
+ while (en.hasMoreElements()) {
+ String key = (String) en.nextElement();
+ String code = new String(properties.getProperty(key).getBytes(
+ "ISO-8859-1"), charsetName);
+ map.put(key, code);
+ }
+ return map;
+ }
+ /**
+ *
+ * @param path
+ * 文件路径
+ * @param suffix
+ * 后缀名
+ * @param isdepth
+ * 是否遍历子目录
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public static List getListFiles(String path, String suffix, boolean isdepth) {
+ File file = new File(path);
+ return FileUtils.listFile(file, suffix, isdepth);
+ }
+
+ /**
+ * @param f
+ * @param suffix:后缀名
+ * @param isdepth:是否遍历子目录
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public static List listFile(File f, String suffix, boolean isdepth) {
+ // 是目录,同时需要遍历子目录
+ List fileList = new ArrayList();
+ if (f.isDirectory() && isdepth == true) {
+ File[] t = f.listFiles();
+ for (int i = 0; i < t.length; i++) {
+ listFile(t[i], suffix, isdepth);
+ }
+ } else {
+ String filePath = f.getAbsolutePath();
+
+ if (suffix != null) {
+ int begIndex = filePath.lastIndexOf(".");// 最后一个.(即后缀名前面的.)的索引
+ String tempsuffix = "";
+
+ if (begIndex != -1)// 防止是文件但却没有后缀名结束的文件
+ {
+ tempsuffix = filePath.substring(begIndex + 1, filePath
+ .length());
+ }
+
+ if (tempsuffix.equals(suffix)) {
+ fileList.add(filePath);
+ }
+ } else {
+ // 后缀名为null则为所有文件
+ fileList.add(filePath);
+ }
+
+ }
+
+ return fileList;
+ }
+
+ /**
+ * 方法追加文件:使用FileWriter
+ *
+ * @param fileName
+ * @param content
+ */
+ public static void appendMethod(String fileName, String content) {
+ try {
+ // 打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
+ FileWriter writer = new FileWriter(fileName, true);
+ writer.write(content + "\r\n");
+ writer.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/src/main/resources/mapper_xml/DepotItemMapperEx.xml b/src/main/resources/mapper_xml/DepotItemMapperEx.xml
index 09c51cc1..d4900218 100644
--- a/src/main/resources/mapper_xml/DepotItemMapperEx.xml
+++ b/src/main/resources/mapper_xml/DepotItemMapperEx.xml
@@ -33,6 +33,14 @@
+
+
+
+
+
+
+
+
-