Browse Source

Merge branch 'master' of http://git.9026.com/Silent/RailwayTwo

ChenWuJie 4 years ago
parent
commit
543a004272

+ 61 - 57
mini/pages/create-order/index.js

xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -64,11 +64,11 @@ Page({
       order_id
     })
     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, '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()
       });
       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
     this.setData({
       selectIndex: newIndex
     })
   },
-  
-  initData: function() {
+
+  initData: function () {
     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;
         break;
       }
     }
     var devices = order.order_devices
     var local_devices = []
-    for(var i = 0; i < devices.length; ++i) {
+    for (var i = 0; i < devices.length; ++i) {
       var device = devices[i]
       local_devices.push({
         type_name: device.device_type ? device.device_type.name : '',
@@ -119,15 +123,15 @@ Page({
     this.updateDeviceStat()
   },
 
-  submit: function(e) {
+  submit: function (e) {
     var type = e.currentTarget.dataset.type
     var is_draft = type == 'draft' ? 1 : 2
     var submit_type = this.data.type
-    if(this.data.pointIndex < 0) {
+    if (this.data.pointIndex < 0) {
       util.error('需求工点必填');
       return false;
     }
-    if(this.data.devices.length <= 0) {
+    if (this.data.devices.length <= 0) {
       util.error('请选择租赁设备');
       return false;
     }
@@ -144,12 +148,12 @@ Page({
         devices: this.data.devices,
         is_draft: is_draft
       },
-      success: function(res) {
-        if(res.code == 0) {
+      success: function (res) {
+        if (res.code == 0) {
           util.success('操作成功')
-          setTimeout(function() {
+          setTimeout(function () {
             var url = '/pages/order/index?id=' + that.data.id
-            if(is_draft == 1) {
+            if (is_draft == 1) {
               wx.navigateBack({
                 delta: 0,
               })
@@ -164,13 +168,13 @@ Page({
     })
   },
 
-  switchTab: function(e) {
+  switchTab: function (e) {
     this.setData({
       tabIndex: e.currentTarget.dataset.index
     })
   },
 
-  deleteDevice: function() {
+  deleteDevice: function () {
     var devices = this.data.devices
     var index = this.data.selectIndex
     devices.splice(index, 1)
@@ -181,18 +185,18 @@ Page({
     this.updateDeviceStat()
   },
 
-  editDevice: function() {
+  editDevice: function () {
     var devices = this.data.devices
     var index = this.data.selectIndex
-    if(index < 0) return false
+    if (index < 0) return false
     var device = devices[index]
     var typeIndex = -1
     var device_types = this.data.device_types
     var default_dates = [device.start_date, device.end_date]
     var names = null
     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;
         names = device_types[i].names
         break;
@@ -201,18 +205,18 @@ Page({
 
     var specs = null
     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
           nameIndex = i;
           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;
           break;
         }
@@ -220,8 +224,8 @@ Page({
     }
     var rent_types = this.data.rent_types
     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;
         break;
       }
@@ -245,7 +249,7 @@ Page({
     })
   },
 
-  getCustom: function(name) {
+  getCustom: function (name) {
     var index = name + 'Index'
     var caseName = util.firstCase(name)
     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('设备类型必填');
       this.stopClose()
       return false;
     }
-    if(!this.getCustom('name')) {
+    if (!this.getCustom('name')) {
       util.error('设备名称必填')
       this.stopClose()
       return false
     }
-    if(!this.getCustom('spec')) {
+    if (!this.getCustom('spec')) {
       util.error('规格型号必填')
       this.stopClose()
       return false
     }
-    if(!this.getCustom('rent')) {
+    if (!this.getCustom('rent')) {
       util.error('租赁方式必填')
       this.stopClose()
       return false
     }
-    if(!this.data.device_quantity) {
+    if (!this.data.device_quantity) {
       util.error('设备数量必填')
       this.stopClose()
       return false
     }
-    if(!this.data.device_price) {
+    if (!this.data.device_price) {
       util.error('设备单价必填')
       this.stopClose()
       return false
     }
-    if(!this.data.start_date) {
+    if (!this.data.start_date) {
       util.error('租赁时间必填')
       this.stopClose()
       return false
@@ -315,7 +319,7 @@ Page({
       end_date: this.data.end_date
     }
     var dialog_type = this.data.dialog_type
-    if(dialog_type == 'create') {
+    if (dialog_type == 'create') {
       devices.push(device)
     } else {
       devices[this.data.selectIndex] = device
@@ -329,15 +333,15 @@ Page({
     })
     this.updateDeviceStat()
   },
-  onClose: function(e) {
-    if(e.detail == 'confirm') return false;
+  onClose: function (e) {
+    if (e.detail == 'confirm') return false;
     return true
   },
   updateDeviceStat() {
     var devices = this.data.devices
     var device_total = devices.length
     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 / 100;
@@ -347,10 +351,10 @@ Page({
     })
   },
 
-  onChange: function(e) {
+  onChange: function (e) {
     var name = e.currentTarget.dataset.name
     var val = e.detail.value
-    if(['customSpec', 'customName', 'customRent'].indexOf(name) != -1) {
+    if (['customSpec', 'customName', 'customRent'].indexOf(name) != -1) {
       val = e.detail;
     }
     this.setData({
@@ -367,18 +371,18 @@ Page({
         device_price: price
       })
     }
-    if(name == 'customName' && val) {
+    if (name == 'customName' && val) {
       this.setData({
         customSpec: true,
       })
     }
-    if(name == 'typeIndex') {
+    if (name == 'typeIndex') {
       this.setData({
         nameIndex: -1,
         specIndex: -1
       })
     }
-    if(name == 'nameIndex') {
+    if (name == 'nameIndex') {
       var device_types = this.data.device_types
       var typeIndex = this.data.typeIndex
       var nameIndex = this.data.nameIndex
@@ -388,7 +392,7 @@ Page({
         specIndex: -1
       })
     }
-    if(name == 'specIndex') {
+    if (name == 'specIndex') {
       var device_types = this.data.device_types
       var typeIndex = this.data.typeIndex
       var nameIndex = this.data.nameIndex
@@ -398,7 +402,7 @@ Page({
         selectSpec: selectSpec
       })
     }
-    if(name == 'rentIndex') {
+    if (name == 'rentIndex') {
       var rent_types = this.data.rent_types
       var rentIndex = this.data.rentIndex
       var selectRent = rent_types[rentIndex].name
@@ -408,9 +412,9 @@ Page({
     }
   },
 
-  switchShowAdd: function(e) {
+  switchShowAdd: function (e) {
     var show = e.currentTarget.dataset.show
-    if(show) {
+    if (show) {
       this.setData({
         device_name: '',
         typeIndex: -1,
@@ -427,13 +431,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)

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

xqd
@@ -99,7 +99,7 @@
     </view>
   </view>
   <van-dialog show="{{ showAdd }}" use-slot title="{{dialog_type == 'create' ? '添加设备' : '修改设备'}}" show-cancel-button
-    bind:confirm="addDevice" z-index="1" data-show="{{false}}" confirm-button-color="#5693FC">
+    bind:confirm="addDevice" bind:cancel="closeshow"  z-index="1" data-show="{{false}}" confirm-button-color="#5693FC">
     <view class="sg-add-device-box sg-pad sg-font-small">
       <view class="sg-form-item sg-pad-tb sg-top-border">
         <view class="sg-label">设备类型</view>

+ 9 - 5
mini/pages/data/index.wxml

xqd
@@ -1,16 +1,20 @@
 <!--pages/data/index.wxml-->
 <view class="sg-container sg-index-bg">
-  <van-popup show="{{ projectShow }}" closeable safe-area-inset-top position="top" bind:close="popclose"
-    custom-style="height: 20%;">
+  <van-popup show="{{ projectShow }}" safe-area-inset-top position="top" custom-style="height: 20%;">
     <van-dropdown-menu active-color="#5992fd">
       <van-dropdown-item value="{{ project_id }}" options="{{ projects }}" bind:change="onChange"
         data-name="project_id" />
       <van-dropdown-item value="{{ sort_type }}" options="{{ sort_types }}" bind:change="onChange"
         data-name="sort_type" />
     </van-dropdown-menu>
-    <view class="sg-pad">
-      <van-button type="info" block bind:click="switchShow" data-show="{{false}}" data-name="projectShow">确定
-      </van-button>
+    <view class="sg-pad sg-flex sg-align-center sg-space-between">
+      <view class="" style="width:300rpx">
+        <van-button size="normal" round  type="info" block bind:click="switchShow" data-show="{{false}}" data-name="projectShow">确定
+        </van-button>
+      </view>
+      <view class=""  style="width:300rpx">
+        <van-button size="normal" round  block bind:click="popclose" color="#737477">取消</van-button>
+      </view>
     </view>
   </van-popup>
   <view class="sg-white sg-bold sg-flex sg-align-center sg-space-around">

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

xqd xqd xqd
@@ -35,8 +35,8 @@
           placeholder="请填写维修原因"></input>
       </view>
       <view class="sg-form-item sg-pad sg-top-border">
-        <view class="sg-label">维修日期</view>
-        <input value="{{day}}" class="sg-input" bindinput="onChange" data-name="day" placeholder="请填写维修天数"></input>
+        <view class="sg-label">维修天数</view>
+        <input value="{{day}}" class="sg-input" bindinput="onChange" type="digit" data-name="day" placeholder="请填写维修天数"></input>
       </view>
       <view class="sg-form-item sg-pad sg-top-border">
         <view class="sg-label">备注</view>
@@ -58,8 +58,8 @@
         </view>
       </view>
       <view class="sg-btns sg-flex sg-align-center sg-space-between sg-white-bg sg-pad-top">
-        <van-button type="danger" class="sg-popup-btn" block bind:click="switchShow" data-name="showDevice">取消</van-button>
-        <van-button type="info" class="sg-popup-btn" block bind:click="switchShow" data-name="showDevice">确认</van-button>
+        <van-button type="danger" color="#737477" class="sg-popup-btn" block bind:click="switchShow" round data-name="showDevice">取消</van-button>
+        <van-button type="info" class="sg-popup-btn" block bind:click="switchShow" round data-name="showDevice">确认</van-button>
       </view>
     </view>
   </van-popup>
@@ -109,7 +109,7 @@
       </view>
       <view class="sg-form-item sg-pad-tb sg-top-border">
         <view class="sg-label">更换配件价格</view>
-        <input value="{{part_price}}" type="number"  class="sg-input" bindinput="onChange" data-name="part_price"
+        <input value="{{part_price}}" type="digit"  class="sg-input" bindinput="onChange" data-name="part_price"
           placeholder="请输入更换配件价格(元)"></input>
       </view>
     </view>

+ 1 - 0
mini/pages/repair/index.wxss

xqd
@@ -32,6 +32,7 @@
 }
 .sg-order-box {
   background: white;
+  margin-top: 88rpx;
 }
 .sg-submit-box {
   justify-content: center;