diff --git a/pages/fixedAssets/add/add.js b/pages/fixedAssets/add/add.js index 4b5ea16..1aac93c 100644 --- a/pages/fixedAssets/add/add.js +++ b/pages/fixedAssets/add/add.js @@ -167,43 +167,44 @@ Page({ return mydate }, goSubmit:function(){ - if(this.data.form.code==''||this.data.form.code==null){ //合同编码 + if(this.data.form.code===''||this.data.form.code==null){ //合同编码 UTIL.showToastNoneIcon('请填写资产编码!'); return false; - }else if(this.data.form.name==''||this.data.form.name==null){ //合同名称 + }else if(this.data.form.name===''||this.data.form.name==null){ //合同名称 UTIL.showToastNoneIcon('请输入资产名称!'); return false; - }else if(this.data.form.assetType==''||this.data.form.assetType==null){ //甲方 + }else if(this.data.form.assetType===''||this.data.form.assetType==null){ //甲方 UTIL.showToastNoneIcon('资产类别不能为空!'); return false; - }else if(this.data.form.operationType==''||this.data.form.operationType==null){ //乙方 + }else if(this.data.form.operationType===''||this.data.form.operationType==null){ //乙方 UTIL.showToastNoneIcon('经营属性不能为空!'); return false; - }else if(this.data.form.addType == ''||this.data.form.addType==null){//收付款类型 + }else if(this.data.form.addType === ''||this.data.form.addType==null){//收付款类型 UTIL.showToastNoneIcon('增加方式能为空!'); return false; - }else if(this.data.form.buildTime == ''||this.data.form.buildTime==null){//合同来源 + }else if(this.data.form.buildTime === ''||this.data.form.buildTime==null){//合同来源 UTIL.showToastNoneIcon('构建时间不能为空!'); return false; - }else if(this.data.form.useType == ''||this.data.form.useType==null){//合同金额 + }else if(this.data.form.useType === ''||this.data.form.useType==null){//合同金额 UTIL.showToastNoneIcon('使用情况不能为空!'); return false; - }else if(this.data.form.assetStatus == ''||this.data.form.assetStatus==null){//签订日期 + }else if(this.data.form.assetStatus === ''||this.data.form.assetStatus==null){//签订日期 UTIL.showToastNoneIcon('资产状态不能为空!'); return false; - }else if(this.data.form.quantity == ''||this.data.form.quantity==null){//开始日期 + }else if(this.data.form.quantity === ''||this.data.form.quantity==null){//开始日期 UTIL.showToastNoneIcon('请输入数量、面积!'); return false; - }else if(this.data.form.unit == ''||this.data.form.unit==null){//结束日期 + }else if(this.data.form.unit === ''||this.data.form.unit==null){//结束日期 UTIL.showToastNoneIcon('计量单位不能为空!'); return false; - }else if(this.data.form.originalValue == ''||this.data.form.originalValue==null){//单价 + }else if(this.data.form.originalValue === ''||this.data.form.originalValue==null){//单价 UTIL.showToastNoneIcon('原值不能为空!'); return false; - }else if(this.data.form.depreciationType == ''||this.data.form.depreciationType==null){//已结款 + }else if(this.data.form.depreciationType === ''||this.data.form.depreciationType==null){//已结款 UTIL.showToastNoneIcon('折旧方式不能为空!'); return false; }else if(this.data.status == '0'){ + let that = this this.setData({'status':'1'}) if(this.data.form.id!=null&&this.data.form.id!=""){ let data = this.data.form; @@ -219,7 +220,7 @@ Page({ },2000) }else{ UTIL.showToastNoneIcon('修改失败'); - this.setData({'status':'0'}) + that.setData({'status':'0'}) } }, fail: function (response) { @@ -228,10 +229,10 @@ Page({ } else { showToastNoneIcon(API.MSG_FAIL_HTTP); } - this.setData({'status':0}) + that.setData({'status':0}) }, complete: function (response) { - this.setData({'status':0}) + that.setData({'status':0}) wx.hideNavigationBarLoading(); } }) @@ -249,7 +250,7 @@ Page({ },2000) }else{ UTIL.showToastNoneIcon(res.msg); - this.setData({'status':'0'}) + that.setData({'status':'0'}) } }, fail: function (response) { @@ -258,10 +259,10 @@ Page({ } else { showToastNoneIcon(API.MSG_FAIL_HTTP); } - this.setData({'status':0}) + that.setData({'status':0}) }, complete: function (response) { - this.setData({'status':0}) + that.setData({'status':0}) wx.hideNavigationBarLoading(); } }) @@ -274,31 +275,40 @@ Page({ }) if(e.currentTarget.dataset.name == 'form.originalValue' ){ this.setData({ - 'form.netValue' : e.detail.value, 'form.netSalvage' : this.data.form.residualsRate*e.detail.value/100, - 'form.perYearDepreciationValue' : (e.detail.value-(this.data.form.residualsRate*e.detail.value/100))/this.data.form.expectedYears.toFixed(2) + 'form.perYearDepreciationValue' : ((e.detail.value-(this.data.form.residualsRate*e.detail.value/100))/this.data.form.expectedYears).toFixed(2) }) - if(e.currentTarget.dataset.name == 'form.residualsRate' ){ + } + if(e.currentTarget.dataset.name == 'form.residualsRate' &&e.detail.value<=100){ + this.setData({ + 'form.netSalvage' : (this.data.form.originalValue*e.detail.value/100)100){ + this.setData({ + 'form.residualsRate' : 5, }) } if(e.currentTarget.dataset.name == 'form.netSalvage' ){ this.setData({ - 'form.perYearDepreciationValue' : (this.data.form.originalValue-e.detail.value)/this.data.form.expectedYears.toFixed(2) + 'form.perYearDepreciationValue' : ((this.data.form.originalValue-e.detail.value)/this.data.form.expectedYears).toFixed(2) }) } if(e.currentTarget.dataset.name == 'form.expectedYears' ){ this.setData({ - 'form.perYearDepreciationValue' : (this.data.form.originalValue-this.data.form.netSalvage)/e.detail.value.toFixed(2) + 'form.perYearDepreciationValue' : ((this.data.form.originalValue-this.data.form.netSalvage)/e.detail.value).toFixed(2) }) } if(e.currentTarget.dataset.name == 'form.depreciationYears' ){ this.setData({ - 'form.depreciationValue' : this.data.form.netSalvage*e.detail.value + 'form.depreciationValue' : (this.data.form.perYearDepreciationValue*e.detail.value)>this.data.form.originalValue?this.data.form.originalValue:(this.data.form.perYearDepreciationValue*e.detail.value).toFixed(2), + 'form.netValue' : (this.data.form.originalValue-(this.data.form.perYearDepreciationValue*e.detail.value))>=0?(this.data.form.originalValue-(this.data.form.perYearDepreciationValue*e.detail.value).toFixed(2)):0 }) } - } + }, /** @@ -507,7 +517,7 @@ Page({ if(res.data.length>0){ that.setData({ assetStatusOptions:res.data, - 'form.assetStatusOptions':res.data[0].dictValue + 'form.assetStatus':res.data[0].dictValue }) } } diff --git a/pages/fixedAssets/add/add.wxml b/pages/fixedAssets/add/add.wxml index 4c76a45..2672417 100644 --- a/pages/fixedAssets/add/add.wxml +++ b/pages/fixedAssets/add/add.wxml @@ -133,7 +133,7 @@ 数量/面积 - + diff --git a/pages/fixedAssets/fixedAssets.js b/pages/fixedAssets/fixedAssets.js index 05b92ec..1f70e48 100644 --- a/pages/fixedAssets/fixedAssets.js +++ b/pages/fixedAssets/fixedAssets.js @@ -57,13 +57,6 @@ Page({ scrollHeight:wx.getSystemInfoSync().windowHeight-res[0].height-res[0].top }) }) - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - //获取附件字典 UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'common_attach', {method:'GET'}, { success: (res) => { @@ -74,8 +67,15 @@ Page({ } } }) - this.getList(); + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, getList:function(){ let params = { @@ -159,7 +159,6 @@ Page({ url: '/pages/fixedAssets/add/add?id='+e.currentTarget.dataset.id, }) }, - delete(e){ this.setData({ 'itemId':e.currentTarget.dataset.id, @@ -342,7 +341,8 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - + this.setData({'pageNums':1}) + this.getList(); }, /**