| xqd
@@ -60,8 +60,12 @@ Page({
|
|
|
if (order_id) {
|
|
|
var that = this
|
|
|
|
|
|
- api.getByName(this, 'orders/detail', 'order', { id: order_id }, function (res) {
|
|
|
- api.getByName(that, 'orders/getRole', 'role', { id: that.data.order ? that.data.order.project_id : '' }, function (res) {
|
|
|
+ api.getByName(this, 'orders/detail', 'order', {
|
|
|
+ id: order_id
|
|
|
+ }, function (res) {
|
|
|
+ api.getByName(that, 'orders/getRole', 'role', {
|
|
|
+ id: that.data.order ? that.data.order.project_id : ''
|
|
|
+ }, function (res) {
|
|
|
that.updateActionType()
|
|
|
that.initData()
|
|
|
});
|
| xqd
@@ -77,7 +81,7 @@ Page({
|
|
|
var role = this.data.role
|
|
|
var order = this.data.order
|
|
|
if (order.level == role.level) {
|
|
|
- if(['checking', 'checked'].indexOf(order.status_key) != -1 && role && role.rights && role.rights.applyCheck) actionType = 'check';
|
|
|
+ if (['checking', 'checked'].indexOf(order.status_key) != -1 && role && role.rights && role.rights.applyCheck) actionType = 'check';
|
|
|
else if (order.status_key == 'reject' && role.key == 'machine') actionType = 're-submit'
|
|
|
else if (order.status_key == 'checked' && role.key == 'machine') actionType = 'back'
|
|
|
}
|
| xqd
@@ -98,7 +102,7 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- switchChecked: function(e) {
|
|
|
+ switchChecked: function (e) {
|
|
|
var index = e.detail.index
|
|
|
var devices = this.data.devices
|
|
|
devices[index].checked = !devices[index].checked
|
| xqd
@@ -107,7 +111,7 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- switchShow: function(e) {
|
|
|
+ switchShow: function (e) {
|
|
|
var name = e.currentTarget.dataset.name
|
|
|
var val = this.data[name]
|
|
|
this.setData({
|
| xqd
@@ -129,14 +133,14 @@ Page({
|
|
|
return false
|
|
|
}
|
|
|
Dialog.confirm({
|
|
|
- title: '提示',
|
|
|
- message: msg,
|
|
|
- })
|
|
|
+ title: '提示',
|
|
|
+ message: msg,
|
|
|
+ })
|
|
|
.then(() => {
|
|
|
that.submitCheck(e)
|
|
|
})
|
|
|
},
|
|
|
- editDate: function(e) {
|
|
|
+ editDate: function (e) {
|
|
|
var deviceIndex = e.detail.index
|
|
|
var device = this.data.devices[deviceIndex]
|
|
|
var default_dates = [device.start_date, device.end_date]
|
| xqd
@@ -153,8 +157,16 @@ Page({
|
|
|
end_date = util.formatDate(end_date)
|
|
|
var devices = this.data.devices
|
|
|
var deviceIndex = this.data.deviceIndex
|
|
|
+ if (this.data.actionType == 'back') {
|
|
|
+ var init_end_date = this.data.devices[deviceIndex].init_end_date
|
|
|
+ if (init_end_date >= start_date) {
|
|
|
+ util.error('该设备还在使用中,请重新选择续租时间')
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
devices[deviceIndex].start_date = start_date
|
|
|
devices[deviceIndex].end_date = end_date
|
|
|
+ devices[deviceIndex].is_change = true
|
|
|
this.setData({
|
|
|
devices,
|
|
|
showDate: false
|
| xqd
@@ -169,16 +181,16 @@ Page({
|
|
|
util.error('请选择调用设备');
|
|
|
return false;
|
|
|
}
|
|
|
- if(type == 'back') {
|
|
|
+ if (type == 'back') {
|
|
|
var devices = this.data.devices
|
|
|
var find = false;
|
|
|
- for(var i = 0; i < devices.length; ++i) {
|
|
|
- if(devices[i].checked) {
|
|
|
+ for (var i = 0; i < devices.length; ++i) {
|
|
|
+ if (devices[i].checked) {
|
|
|
find = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if(!find) {
|
|
|
+ if (!find) {
|
|
|
util.error('归还设备不能为空');
|
|
|
return false;
|
|
|
}
|
| xqd
@@ -235,7 +247,14 @@ Page({
|
|
|
util.error('请选择调用设备');
|
|
|
return false;
|
|
|
}
|
|
|
- if(type == 're-rent') {
|
|
|
+ if (type == 're-rent') {
|
|
|
+ var devices = this.data.devices
|
|
|
+ for (var i = 0; i < devices.length; ++i) {
|
|
|
+ if (devices[i].start_date <= devices[i].init_end_date) {
|
|
|
+ util.error('有设备还在使用中,请重新选择续租时间')
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
this.setData({
|
|
|
showRent: false
|
|
|
})
|
| xqd
@@ -258,9 +277,9 @@ Page({
|
|
|
success: function (res) {
|
|
|
if (res.code == 0) {
|
|
|
util.success('操作成功')
|
|
|
- setTimeout(function() {
|
|
|
+ setTimeout(function () {
|
|
|
var url = '/pages/order-inner/index?id=' + that.data.id
|
|
|
- if(is_draft == 1) {
|
|
|
+ if (is_draft == 1) {
|
|
|
wx.navigateBack({
|
|
|
delta: 0,
|
|
|
})
|