李浩杰 4 years ago
parent
commit
06a0268189

+ 2 - 0
app/Http/Controllers/Api/mini/OrderController.php

xqd
@@ -278,6 +278,8 @@ class OrderController extends BaseController
             $device->status = Option::find($device->status);
             $device->spec = Spec::find($device->spec);
             $device->work_point = $order['workPoint'];
+            $device->init_start_date = $device->start_date;
+            $device->init_end_date = $device->end_date;
         }
         foreach($order['order_devices'] as $order_device) {
             $order_device->device_type = Device::find($order_device->device_id);

+ 35 - 16
mini/pages/create-order-inner/index.js

xqd xqd xqd xqd xqd xqd xqd xqd 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()
         });
@@ -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'
     }
@@ -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
@@ -107,7 +111,7 @@ Page({
     })
   },
 
-  switchShow: function(e) {
+  switchShow: function (e) {
     var name = e.currentTarget.dataset.name
     var val = this.data[name]
     this.setData({
@@ -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]
@@ -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
@@ -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;
       }
@@ -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
       })
@@ -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,
               })

+ 1 - 1
mini/pages/create-order-inner/index.wxml

xqd
@@ -92,7 +92,7 @@
       </block>
     </view>
   </view>
-  <van-calendar show="{{ showDate }}" bind:close="switchShow" bind:confirm="confirmDate" data-show="{{false}}"
+  <van-calendar show="{{ showDate }}" bind:close="switchShow" bind:confirm="confirmDate" data-name="showDate"
     type="range" class="sg-calendar" default-date="{{default_dates}}" />
   <block wx:if="{{tabIndex == 1 &&  canEdit}}">
     <view class="sg-submit-box sg-pad sg-fix-bottom sg-flex sg-align-center sg-center" bindtap="goAdd"

+ 1 - 1
mini/pages/repair/index.wxml

xqd
@@ -26,7 +26,7 @@
         <picker bindchange="onChange" value="{{deviceIndex}}" range="{{inner_devices}}" range-key="name"
           data-name="deviceIndex" class="sg-input">
           <view class="picker sg-gray-color">
-            {{deviceIndex >= 0 ? inner_devices[deviceIndex].name : '选择需要维修的设备'}}
+            <view>{{deviceIndex >= 0 ? inner_devices[deviceIndex].name : '选择需要维修的设备'}}</view>
           </view>
         </picker>
       </view>