| xqd
@@ -45,14 +45,14 @@ Page({
|
|
|
})
|
|
|
api.getProject(this)
|
|
|
api.getByName(this, 'work-points/get', 'work_points');
|
|
|
- api.getByName(this, 'inner-devices/get', 'inner_devices', {project_id:id, status: 'using'});
|
|
|
+ api.getByName(this, 'inner-devices/get', 'inner_devices', { project_id: id, status: 'using' });
|
|
|
},
|
|
|
|
|
|
switchChecked(e) {
|
|
|
var name = e.currentTarget.dataset.name
|
|
|
var items = this.data[name]
|
|
|
var index = e.currentTarget.dataset.index
|
|
|
- for(var i = 0; i < items.length; ++i) {
|
|
|
+ for (var i = 0; i < items.length; ++i) {
|
|
|
items[i].checked = false;
|
|
|
}
|
|
|
items[index].checked = true;
|
| xqd
@@ -62,12 +62,12 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- submit: function(e) {
|
|
|
+ submit: function (e) {
|
|
|
// if(this.data.pointIndex < 0) {
|
|
|
// util.error('需求工点必填');
|
|
|
// return false;
|
|
|
// }
|
|
|
- if(this.data.deviceIndex < 0) {
|
|
|
+ if (this.data.deviceIndex < 0) {
|
|
|
util.error('维修设备必填');
|
|
|
return false;
|
|
|
}
|
| xqd
@@ -86,10 +86,10 @@ Page({
|
|
|
remark: this.data.remark,
|
|
|
parts: this.data.parts
|
|
|
},
|
|
|
- success: function(res) {
|
|
|
- if(res.code == 0) {
|
|
|
+ success: function (res) {
|
|
|
+ if (res.code == 0) {
|
|
|
util.success('操作成功')
|
|
|
- setTimeout(function() {
|
|
|
+ setTimeout(function () {
|
|
|
wx.navigateBack({
|
|
|
delta: 0,
|
|
|
})
|
| xqd
@@ -99,13 +99,13 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- switchTab: function(e) {
|
|
|
+ switchTab: function (e) {
|
|
|
this.setData({
|
|
|
tabIndex: e.currentTarget.dataset.index
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- delete: function(e) {
|
|
|
+ delete: function (e) {
|
|
|
var parts = this.data.parts
|
|
|
var index = e.currentTarget.dataset.index
|
|
|
parts.splice(index, 1)
|
| xqd
@@ -114,16 +114,16 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- add: function() {
|
|
|
- if(!this.data.part_name) {
|
|
|
+ add: function () {
|
|
|
+ if (!this.data.part_name) {
|
|
|
util.error('维修部位必填');
|
|
|
return false;
|
|
|
}
|
|
|
- if(!this.data.part_change) {
|
|
|
+ if (!this.data.part_change) {
|
|
|
util.error('更换配件必填');
|
|
|
return false;
|
|
|
}
|
|
|
- if(!this.data.part_price) {
|
|
|
+ if (!this.data.part_price) {
|
|
|
util.error('配件价格必填');
|
|
|
return false;
|
|
|
}
|
| xqd
@@ -139,21 +139,30 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- onChange: function(e) {
|
|
|
+ onChange: function (e) {
|
|
|
var name = e.currentTarget.dataset.name
|
|
|
var val = e.detail.value
|
|
|
-
|
|
|
this.setData({
|
|
|
[name]: val
|
|
|
})
|
|
|
-
|
|
|
- if(name == 'pointIndex') {
|
|
|
+ if (name == 'part_price') {
|
|
|
+ let price
|
|
|
+ if (/^(\d?)+(\.\d{0,2})?$/.test(val)) { //正则验证,提现金额小数点后不能大于两位数字
|
|
|
+ price = val;
|
|
|
+ } else {
|
|
|
+ price = val.substring(0, val.length - 1);
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ part_price: price
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (name == 'pointIndex') {
|
|
|
var work_point = this.data.work_points[val]
|
|
|
var work_point_id = work_point ? work_point.id : ''
|
|
|
var that = this
|
|
|
api.getByName(this, 'inner-devices/get', 'inner_devices', {
|
|
|
work_point_id: work_point_id
|
|
|
- }, function() {
|
|
|
+ }, function () {
|
|
|
that.setData({
|
|
|
deviceIndex: -1
|
|
|
})
|
| xqd
@@ -169,9 +178,9 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- switchShowAdd: function(e) {
|
|
|
+ switchShowAdd: function (e) {
|
|
|
var show = e.currentTarget.dataset.show
|
|
|
- if(show) {
|
|
|
+ if (show) {
|
|
|
this.setData({
|
|
|
part_name: '',
|
|
|
part_change: '',
|
| xqd
@@ -184,13 +193,13 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- switchShowDate: function(e) {
|
|
|
+ switchShowDate: function (e) {
|
|
|
this.setData({
|
|
|
showDate: e.currentTarget.dataset.show
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- confirmDate: function(e) {
|
|
|
+ confirmDate: function (e) {
|
|
|
this.switchShowDate(e)
|
|
|
var [start_date, end_date] = e.detail;
|
|
|
start_date = util.formatDate(start_date)
|