|
@@ -64,11 +64,11 @@ Page({
|
|
order_id
|
|
order_id
|
|
})
|
|
})
|
|
api.getProject(this)
|
|
api.getProject(this)
|
|
- api.getByName(this, 'work-points/get', 'work_points', {project_id: id});
|
|
|
|
|
|
+ api.getByName(this, 'work-points/get', 'work_points', { project_id: id });
|
|
api.getByName(this, 'devices/getThreeLevel', 'device_types');
|
|
api.getByName(this, 'devices/getThreeLevel', 'device_types');
|
|
api.getByName(this, 'rent-types/get', 'rent_types');
|
|
api.getByName(this, 'rent-types/get', 'rent_types');
|
|
- if(order_id) {
|
|
|
|
- api.getByName(this, 'orders/detail', 'order', {id: order_id}, function(res) {
|
|
|
|
|
|
+ if (order_id) {
|
|
|
|
+ api.getByName(this, 'orders/detail', 'order', { id: order_id }, function (res) {
|
|
that.initData()
|
|
that.initData()
|
|
});
|
|
});
|
|
wx.setNavigationBarTitle({
|
|
wx.setNavigationBarTitle({
|
|
@@ -76,28 +76,32 @@ Page({
|
|
})
|
|
})
|
|
}
|
|
}
|
|
},
|
|
},
|
|
-
|
|
|
|
- selectDevice: function(e) {
|
|
|
|
|
|
+ closeshow() {
|
|
|
|
+ this.setData({
|
|
|
|
+ showAdd: false
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ selectDevice: function (e) {
|
|
var newIndex = e.currentTarget.dataset.index == this.data.selectIndex ? -1 : e.currentTarget.dataset.index
|
|
var newIndex = e.currentTarget.dataset.index == this.data.selectIndex ? -1 : e.currentTarget.dataset.index
|
|
this.setData({
|
|
this.setData({
|
|
selectIndex: newIndex
|
|
selectIndex: newIndex
|
|
})
|
|
})
|
|
},
|
|
},
|
|
-
|
|
|
|
- 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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var devices = order.order_devices
|
|
var devices = order.order_devices
|
|
var local_devices = []
|
|
var local_devices = []
|
|
- for(var i = 0; i < devices.length; ++i) {
|
|
|
|
|
|
+ for (var i = 0; i < devices.length; ++i) {
|
|
var device = devices[i]
|
|
var device = devices[i]
|
|
local_devices.push({
|
|
local_devices.push({
|
|
type_name: device.device_type ? device.device_type.name : '',
|
|
type_name: device.device_type ? device.device_type.name : '',
|
|
@@ -119,15 +123,15 @@ Page({
|
|
this.updateDeviceStat()
|
|
this.updateDeviceStat()
|
|
},
|
|
},
|
|
|
|
|
|
- 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;
|
|
}
|
|
}
|
|
@@ -144,12 +148,12 @@ Page({
|
|
devices: this.data.devices,
|
|
devices: this.data.devices,
|
|
is_draft: is_draft
|
|
is_draft: is_draft
|
|
},
|
|
},
|
|
- success: function(res) {
|
|
|
|
- if(res.code == 0) {
|
|
|
|
|
|
+ success: function (res) {
|
|
|
|
+ if (res.code == 0) {
|
|
util.success('操作成功')
|
|
util.success('操作成功')
|
|
- setTimeout(function() {
|
|
|
|
|
|
+ setTimeout(function () {
|
|
var url = '/pages/order/index?id=' + that.data.id
|
|
var url = '/pages/order/index?id=' + that.data.id
|
|
- if(is_draft == 1) {
|
|
|
|
|
|
+ if (is_draft == 1) {
|
|
wx.navigateBack({
|
|
wx.navigateBack({
|
|
delta: 0,
|
|
delta: 0,
|
|
})
|
|
})
|
|
@@ -164,13 +168,13 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- switchTab: function(e) {
|
|
|
|
|
|
+ switchTab: function (e) {
|
|
this.setData({
|
|
this.setData({
|
|
tabIndex: e.currentTarget.dataset.index
|
|
tabIndex: e.currentTarget.dataset.index
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- deleteDevice: function() {
|
|
|
|
|
|
+ deleteDevice: function () {
|
|
var devices = this.data.devices
|
|
var devices = this.data.devices
|
|
var index = this.data.selectIndex
|
|
var index = this.data.selectIndex
|
|
devices.splice(index, 1)
|
|
devices.splice(index, 1)
|
|
@@ -181,18 +185,18 @@ Page({
|
|
this.updateDeviceStat()
|
|
this.updateDeviceStat()
|
|
},
|
|
},
|
|
|
|
|
|
- editDevice: function() {
|
|
|
|
|
|
+ editDevice: function () {
|
|
var devices = this.data.devices
|
|
var devices = this.data.devices
|
|
var index = this.data.selectIndex
|
|
var index = this.data.selectIndex
|
|
- if(index < 0) return false
|
|
|
|
|
|
+ if (index < 0) return false
|
|
var device = devices[index]
|
|
var device = devices[index]
|
|
var typeIndex = -1
|
|
var typeIndex = -1
|
|
var device_types = this.data.device_types
|
|
var device_types = this.data.device_types
|
|
var default_dates = [device.start_date, device.end_date]
|
|
var default_dates = [device.start_date, device.end_date]
|
|
var names = null
|
|
var names = null
|
|
var nameIndex = -1
|
|
var nameIndex = -1
|
|
- for(var i = 0; i < device_types.length; ++i) {
|
|
|
|
- if(device_types[i].id == device.type_id) {
|
|
|
|
|
|
+ for (var i = 0; i < device_types.length; ++i) {
|
|
|
|
+ if (device_types[i].id == device.type_id) {
|
|
typeIndex = i;
|
|
typeIndex = i;
|
|
names = device_types[i].names
|
|
names = device_types[i].names
|
|
break;
|
|
break;
|
|
@@ -201,18 +205,18 @@ Page({
|
|
|
|
|
|
var specs = null
|
|
var specs = null
|
|
var specIndex = -1
|
|
var specIndex = -1
|
|
- if(names) {
|
|
|
|
- for(var i = 0; i < names.length; ++i) {
|
|
|
|
- if(names[i].name == device.name) {
|
|
|
|
|
|
+ if (names) {
|
|
|
|
+ for (var i = 0; i < names.length; ++i) {
|
|
|
|
+ if (names[i].name == device.name) {
|
|
specs = names[i].specs
|
|
specs = names[i].specs
|
|
nameIndex = i;
|
|
nameIndex = i;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(specs) {
|
|
|
|
- for(var i = 0; i < specs.length; ++i) {
|
|
|
|
- if(specs[i].name == device.spec) {
|
|
|
|
|
|
+ if (specs) {
|
|
|
|
+ for (var i = 0; i < specs.length; ++i) {
|
|
|
|
+ if (specs[i].name == device.spec) {
|
|
specIndex = i;
|
|
specIndex = i;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -220,8 +224,8 @@ Page({
|
|
}
|
|
}
|
|
var rent_types = this.data.rent_types
|
|
var rent_types = this.data.rent_types
|
|
var rentIndex = -1;
|
|
var rentIndex = -1;
|
|
- for(var i = 0; i < rent_types.length; ++i) {
|
|
|
|
- if(rent_types[i].name == device.rent) {
|
|
|
|
|
|
+ for (var i = 0; i < rent_types.length; ++i) {
|
|
|
|
+ if (rent_types[i].name == device.rent) {
|
|
rentIndex = i;
|
|
rentIndex = i;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -245,7 +249,7 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- getCustom: function(name) {
|
|
|
|
|
|
+ getCustom: function (name) {
|
|
var index = name + 'Index'
|
|
var index = name + 'Index'
|
|
var caseName = util.firstCase(name)
|
|
var caseName = util.firstCase(name)
|
|
var custom = 'custom' + caseName
|
|
var custom = 'custom' + caseName
|
|
@@ -261,38 +265,38 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- addDevice: function() {
|
|
|
|
- if(this.data.typeIndex < 0) {
|
|
|
|
|
|
+ addDevice: function () {
|
|
|
|
+ if (this.data.typeIndex < 0) {
|
|
util.error('设备类型必填');
|
|
util.error('设备类型必填');
|
|
this.stopClose()
|
|
this.stopClose()
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- if(!this.getCustom('name')) {
|
|
|
|
|
|
+ if (!this.getCustom('name')) {
|
|
util.error('设备名称必填')
|
|
util.error('设备名称必填')
|
|
this.stopClose()
|
|
this.stopClose()
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
- if(!this.getCustom('spec')) {
|
|
|
|
|
|
+ if (!this.getCustom('spec')) {
|
|
util.error('规格型号必填')
|
|
util.error('规格型号必填')
|
|
this.stopClose()
|
|
this.stopClose()
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
- if(!this.getCustom('rent')) {
|
|
|
|
|
|
+ if (!this.getCustom('rent')) {
|
|
util.error('租赁方式必填')
|
|
util.error('租赁方式必填')
|
|
this.stopClose()
|
|
this.stopClose()
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
- if(!this.data.device_quantity) {
|
|
|
|
|
|
+ if (!this.data.device_quantity) {
|
|
util.error('设备数量必填')
|
|
util.error('设备数量必填')
|
|
this.stopClose()
|
|
this.stopClose()
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
- if(!this.data.device_price) {
|
|
|
|
|
|
+ if (!this.data.device_price) {
|
|
util.error('设备单价必填')
|
|
util.error('设备单价必填')
|
|
this.stopClose()
|
|
this.stopClose()
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
- if(!this.data.start_date) {
|
|
|
|
|
|
+ if (!this.data.start_date) {
|
|
util.error('租赁时间必填')
|
|
util.error('租赁时间必填')
|
|
this.stopClose()
|
|
this.stopClose()
|
|
return false
|
|
return false
|
|
@@ -315,7 +319,7 @@ Page({
|
|
end_date: this.data.end_date
|
|
end_date: this.data.end_date
|
|
}
|
|
}
|
|
var dialog_type = this.data.dialog_type
|
|
var dialog_type = this.data.dialog_type
|
|
- if(dialog_type == 'create') {
|
|
|
|
|
|
+ if (dialog_type == 'create') {
|
|
devices.push(device)
|
|
devices.push(device)
|
|
} else {
|
|
} else {
|
|
devices[this.data.selectIndex] = device
|
|
devices[this.data.selectIndex] = device
|
|
@@ -329,15 +333,15 @@ Page({
|
|
})
|
|
})
|
|
this.updateDeviceStat()
|
|
this.updateDeviceStat()
|
|
},
|
|
},
|
|
- onClose: function(e) {
|
|
|
|
- if(e.detail == 'confirm') return false;
|
|
|
|
|
|
+ onClose: function (e) {
|
|
|
|
+ if (e.detail == 'confirm') return false;
|
|
return true
|
|
return true
|
|
},
|
|
},
|
|
updateDeviceStat() {
|
|
updateDeviceStat() {
|
|
var devices = this.data.devices
|
|
var devices = this.data.devices
|
|
var device_total = devices.length
|
|
var device_total = devices.length
|
|
var device_money = 0
|
|
var device_money = 0
|
|
- for(var i = 0; i < devices.length; ++i) {
|
|
|
|
|
|
+ for (var i = 0; i < devices.length; ++i) {
|
|
device_money = device_money + Math.round(parseFloat(devices[i].price) * parseInt(devices[i].quantity) * 100)
|
|
device_money = device_money + Math.round(parseFloat(devices[i].price) * parseInt(devices[i].quantity) * 100)
|
|
}
|
|
}
|
|
device_money = device_money / 100;
|
|
device_money = device_money / 100;
|
|
@@ -347,10 +351,10 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- onChange: function(e) {
|
|
|
|
|
|
+ onChange: function (e) {
|
|
var name = e.currentTarget.dataset.name
|
|
var name = e.currentTarget.dataset.name
|
|
var val = e.detail.value
|
|
var val = e.detail.value
|
|
- if(['customSpec', 'customName', 'customRent'].indexOf(name) != -1) {
|
|
|
|
|
|
+ if (['customSpec', 'customName', 'customRent'].indexOf(name) != -1) {
|
|
val = e.detail;
|
|
val = e.detail;
|
|
}
|
|
}
|
|
this.setData({
|
|
this.setData({
|
|
@@ -367,18 +371,18 @@ Page({
|
|
device_price: price
|
|
device_price: price
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- if(name == 'customName' && val) {
|
|
|
|
|
|
+ if (name == 'customName' && val) {
|
|
this.setData({
|
|
this.setData({
|
|
customSpec: true,
|
|
customSpec: true,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- if(name == 'typeIndex') {
|
|
|
|
|
|
+ if (name == 'typeIndex') {
|
|
this.setData({
|
|
this.setData({
|
|
nameIndex: -1,
|
|
nameIndex: -1,
|
|
specIndex: -1
|
|
specIndex: -1
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- if(name == 'nameIndex') {
|
|
|
|
|
|
+ if (name == 'nameIndex') {
|
|
var device_types = this.data.device_types
|
|
var device_types = this.data.device_types
|
|
var typeIndex = this.data.typeIndex
|
|
var typeIndex = this.data.typeIndex
|
|
var nameIndex = this.data.nameIndex
|
|
var nameIndex = this.data.nameIndex
|
|
@@ -388,7 +392,7 @@ Page({
|
|
specIndex: -1
|
|
specIndex: -1
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- if(name == 'specIndex') {
|
|
|
|
|
|
+ if (name == 'specIndex') {
|
|
var device_types = this.data.device_types
|
|
var device_types = this.data.device_types
|
|
var typeIndex = this.data.typeIndex
|
|
var typeIndex = this.data.typeIndex
|
|
var nameIndex = this.data.nameIndex
|
|
var nameIndex = this.data.nameIndex
|
|
@@ -398,7 +402,7 @@ Page({
|
|
selectSpec: selectSpec
|
|
selectSpec: selectSpec
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- if(name == 'rentIndex') {
|
|
|
|
|
|
+ if (name == 'rentIndex') {
|
|
var rent_types = this.data.rent_types
|
|
var rent_types = this.data.rent_types
|
|
var rentIndex = this.data.rentIndex
|
|
var rentIndex = this.data.rentIndex
|
|
var selectRent = rent_types[rentIndex].name
|
|
var selectRent = rent_types[rentIndex].name
|
|
@@ -408,9 +412,9 @@ Page({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
- switchShowAdd: function(e) {
|
|
|
|
|
|
+ switchShowAdd: function (e) {
|
|
var show = e.currentTarget.dataset.show
|
|
var show = e.currentTarget.dataset.show
|
|
- if(show) {
|
|
|
|
|
|
+ if (show) {
|
|
this.setData({
|
|
this.setData({
|
|
device_name: '',
|
|
device_name: '',
|
|
typeIndex: -1,
|
|
typeIndex: -1,
|
|
@@ -427,13 +431,13 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- switchShowDate: function(e) {
|
|
|
|
|
|
+ switchShowDate: function (e) {
|
|
this.setData({
|
|
this.setData({
|
|
showDate: e.currentTarget.dataset.show
|
|
showDate: e.currentTarget.dataset.show
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- confirmDate: function(e) {
|
|
|
|
|
|
+ confirmDate: function (e) {
|
|
this.switchShowDate(e)
|
|
this.switchShowDate(e)
|
|
var [start_date, end_date] = e.detail;
|
|
var [start_date, end_date] = e.detail;
|
|
start_date = util.formatDate(start_date)
|
|
start_date = util.formatDate(start_date)
|