|
@@ -53,11 +53,11 @@ Page({
|
|
var order_id = this.data.order_id
|
|
var order_id = this.data.order_id
|
|
api.getProject(this)
|
|
api.getProject(this)
|
|
api.getByName(this, 'work-points/get', 'work_points');
|
|
api.getByName(this, 'work-points/get', 'work_points');
|
|
- if(order_id) {
|
|
|
|
|
|
+ if (order_id) {
|
|
var that = this
|
|
var that = this
|
|
-
|
|
|
|
- api.getByName(this, 'orders/detail', 'order', {id: order_id}, function(res) {
|
|
|
|
- api.getByName(that, 'orders/getRole', 'role', {id: order_id}, function (res) {
|
|
|
|
|
|
+
|
|
|
|
+ api.getByName(this, 'orders/detail', 'order', { id: order_id }, function (res) {
|
|
|
|
+ api.getByName(that, 'orders/getRole', 'role', { id: order_id }, function (res) {
|
|
that.updateActionType()
|
|
that.updateActionType()
|
|
that.initData()
|
|
that.initData()
|
|
});
|
|
});
|
|
@@ -73,13 +73,13 @@ Page({
|
|
var role = this.data.role
|
|
var role = this.data.role
|
|
var order = this.data.order
|
|
var order = this.data.order
|
|
if (order.project_role_id == role.id) {
|
|
if (order.project_role_id == role.id) {
|
|
- if(order.status_key == 'checking' && role.project_role.key == 'assist') actionType = 'check'
|
|
|
|
- else if(order.status_key == 'checked' && ['manager', 'admin'].indexOf(role.project_role.key) != -1) actionType = 'check'
|
|
|
|
- else if(order.status_key == 'reject' && role.project_role.key == 'machine') actionType = 're-submit'
|
|
|
|
- else if(order.status_key == 'pass' && role.project_role.key == 'machine') actionType = 'back'
|
|
|
|
|
|
+ if (order.status_key == 'checking' && role.project_role.key == 'assist') actionType = 'check'
|
|
|
|
+ else if (order.status_key == 'checked' && ['manager', 'admin'].indexOf(role.project_role.key) != -1) actionType = 'check'
|
|
|
|
+ else if (order.status_key == 'reject' && role.project_role.key == 'machine') actionType = 're-submit'
|
|
|
|
+ else if (order.status_key == 'pass' && role.project_role.key == 'machine') actionType = 'back'
|
|
}
|
|
}
|
|
var canEdit = actionType == 'check' && role.project_role.key == 'admin' || (actionType == 're-submit');
|
|
var canEdit = actionType == 'check' && role.project_role.key == 'admin' || (actionType == 're-submit');
|
|
- if(order.is_draft == 1) {
|
|
|
|
|
|
+ if (order.is_draft == 1) {
|
|
canEdit = true
|
|
canEdit = true
|
|
actionType = 'edit'
|
|
actionType = 'edit'
|
|
}
|
|
}
|
|
@@ -89,19 +89,19 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- navigate: function(e) {
|
|
|
|
|
|
+ navigate: function (e) {
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
url: e.currentTarget.dataset.url,
|
|
url: e.currentTarget.dataset.url,
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- check: function(e) {
|
|
|
|
|
|
+ check: function (e) {
|
|
var type = e.currentTarget.dataset.type
|
|
var type = e.currentTarget.dataset.type
|
|
var that = this
|
|
var that = this
|
|
var msg = '确认通过审核吗?'
|
|
var msg = '确认通过审核吗?'
|
|
- if(type == 'reject') msg = '确认驳回申请吗?'
|
|
|
|
- else if(type == 'pass' || type == 're-submit') msg = '确认提交吗?'
|
|
|
|
- else if(type == 'back') msg = '确认归还吗?'
|
|
|
|
|
|
+ if (type == 'reject') msg = '确认驳回申请吗?'
|
|
|
|
+ else if (type == 'pass' || type == 're-submit') msg = '确认提交吗?'
|
|
|
|
+ else if (type == 'back') msg = '确认归还吗?'
|
|
Dialog.confirm({
|
|
Dialog.confirm({
|
|
title: '提示',
|
|
title: '提示',
|
|
message: msg,
|
|
message: msg,
|
|
@@ -114,7 +114,7 @@ Page({
|
|
var type = e.currentTarget.dataset.type
|
|
var type = e.currentTarget.dataset.type
|
|
var is_change = e.currentTarget.dataset.change
|
|
var is_change = e.currentTarget.dataset.change
|
|
var that = this
|
|
var that = this
|
|
- if(this.data.devices.length <= 0) {
|
|
|
|
|
|
+ if (this.data.devices.length <= 0) {
|
|
util.error('请选择调用设备');
|
|
util.error('请选择调用设备');
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -130,21 +130,21 @@ Page({
|
|
success: function (res) {
|
|
success: function (res) {
|
|
if (res.code == 0) {
|
|
if (res.code == 0) {
|
|
util.success('操作成功')
|
|
util.success('操作成功')
|
|
- setTimeout(function() {
|
|
|
|
|
|
+ setTimeout(function () {
|
|
that.init()
|
|
that.init()
|
|
}, 1000)
|
|
}, 1000)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
-
|
|
|
|
- initData: function() {
|
|
|
|
|
|
+
|
|
|
|
+ initData: function () {
|
|
var order = this.data.order,
|
|
var order = this.data.order,
|
|
- work_points = this.data.work_points,
|
|
|
|
- pointIndex = this.data.pointIndex
|
|
|
|
|
|
+ work_points = this.data.work_points,
|
|
|
|
+ pointIndex = this.data.pointIndex
|
|
|
|
|
|
- for(var i = 0; i < work_points.length; ++i) {
|
|
|
|
- if(work_points[i].id == order.work_point_id) {
|
|
|
|
|
|
+ for (var i = 0; i < work_points.length; ++i) {
|
|
|
|
+ if (work_points[i].id == order.work_point_id) {
|
|
pointIndex = i;
|
|
pointIndex = i;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -157,15 +157,15 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- submit: function(e) {
|
|
|
|
|
|
+ submit: function (e) {
|
|
var type = e.currentTarget.dataset.type
|
|
var type = e.currentTarget.dataset.type
|
|
var is_draft = type == 'draft' ? 1 : 2
|
|
var is_draft = type == 'draft' ? 1 : 2
|
|
var submit_type = this.data.type
|
|
var submit_type = this.data.type
|
|
- if(this.data.pointIndex < 0) {
|
|
|
|
|
|
+ if (this.data.pointIndex < 0) {
|
|
util.error('需求工点必填');
|
|
util.error('需求工点必填');
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- if(this.data.devices.length <= 0) {
|
|
|
|
|
|
+ if (this.data.devices.length <= 0) {
|
|
util.error('请选择调用设备');
|
|
util.error('请选择调用设备');
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -183,21 +183,21 @@ Page({
|
|
is_draft: is_draft,
|
|
is_draft: is_draft,
|
|
type: type
|
|
type: type
|
|
},
|
|
},
|
|
- success: function(res) {
|
|
|
|
- if(res.code == 0) {
|
|
|
|
|
|
+ success: function (res) {
|
|
|
|
+ if (res.code == 0) {
|
|
util.success('操作成功')
|
|
util.success('操作成功')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- switchTab: function(e) {
|
|
|
|
|
|
+ switchTab: function (e) {
|
|
this.setData({
|
|
this.setData({
|
|
tabIndex: e.currentTarget.dataset.index
|
|
tabIndex: e.currentTarget.dataset.index
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- onChange: function(e) {
|
|
|
|
|
|
+ onChange: function (e) {
|
|
var name = e.currentTarget.dataset.name
|
|
var name = e.currentTarget.dataset.name
|
|
this.setData({
|
|
this.setData({
|
|
[name]: e.detail.value
|
|
[name]: e.detail.value
|
|
@@ -215,7 +215,7 @@ Page({
|
|
* 生命周期函数--监听页面显示
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
*/
|
|
onShow: function () {
|
|
onShow: function () {
|
|
- if(this.data.type == 'create' || this.data.loadedOrder) {
|
|
|
|
|
|
+ if (this.data.type == 'create' || this.data.loadedOrder) {
|
|
var devices = wx.getStorageSync('sg-added-devices')
|
|
var devices = wx.getStorageSync('sg-added-devices')
|
|
devices = devices ? devices : []
|
|
devices = devices ? devices : []
|
|
this.setData({
|
|
this.setData({
|
|
@@ -224,18 +224,26 @@ Page({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
- goAdd: function(e) {
|
|
|
|
|
|
+ goAdd: function (e) {
|
|
var devices = this.data.devices
|
|
var devices = this.data.devices
|
|
wx.setStorageSync('sg-added-devices', devices)
|
|
wx.setStorageSync('sg-added-devices', devices)
|
|
this.navigate(e)
|
|
this.navigate(e)
|
|
},
|
|
},
|
|
|
|
|
|
- deleteDevice: function(e) {
|
|
|
|
- var index = e.currentTarget.dataset.index
|
|
|
|
- var devices = this.data.devices
|
|
|
|
- devices.splice(index, 1)
|
|
|
|
- this.setData({
|
|
|
|
- devices
|
|
|
|
|
|
+ deleteDevice: function (e) {
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: "提示",
|
|
|
|
+ content: "是否确定删除",
|
|
|
|
+ success: (res) => {
|
|
|
|
+ if (res.confirm) {
|
|
|
|
+ var index = e.currentTarget.dataset.index
|
|
|
|
+ var devices = this.data.devices
|
|
|
|
+ devices.splice(index, 1)
|
|
|
|
+ this.setData({
|
|
|
|
+ devices
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|