李浩杰 hace 4 años
padre
commit
41dc799e43

+ 11 - 1
app/Http/Controllers/Api/mini/DeviceNameController.php

xqd
@@ -18,7 +18,17 @@ class DeviceNameController extends BaseController
     public function get(Request $request)
     {
         if($request->input('type') == 'drop_menu') {
-            $items = $this->model->select('name as text', 'id as value')->get();
+            $items = $this->model;
+            if($request->input('device_ids')) {
+                $device_ids = $request->input('device_ids');
+                $device_ids = array_filter($device_ids, function($item) {
+                    return $item;
+                });
+                if(count($device_ids) > 0) {
+                    $items = $items->whereIn('device_id', $device_ids);
+                }
+            }
+            $items = $items->select('name as text', 'id as value')->get();
             $items = $items->prepend(collect(['text' => '设备名称', 'value' => '']));
             return $this->success(['data' => $items]);
         }

+ 1 - 1
app/Http/Controllers/Api/mini/RentTypeController.php

xqd
@@ -18,7 +18,7 @@ class RentTypeController extends BaseController
     {
         if($request->input('type') == 'drop_menu') {
             $items = $this->model->select('name as text', 'id as value')->get();
-            $items = $items->prepend(collect(['text' => '型号规格', 'value' => '']));
+            $items = $items->prepend(collect(['text' => '租赁方式', 'value' => '']));
             return $this->success(['data' => $items]);
         }
         $items = $this->model->get();

+ 11 - 1
app/Http/Controllers/Api/mini/SpecController.php

xqd
@@ -17,7 +17,17 @@ class SpecController extends BaseController
     public function get(Request $request)
     {
         if($request->input('type') == 'drop_menu') {
-            $items = $this->model->select('name as text', 'id as value')->get();
+            $items = $this->model;
+            if($request->input('device_name_ids')) {
+                $device_name_ids = $request->input('device_name_ids');
+                $device_name_ids = array_filter($device_name_ids, function($item) {
+                    return $item;
+                });
+                if(count($device_name_ids) > 0) {
+                    $items = $items->whereIn('device_name_id', $device_name_ids);
+                }
+            }
+            $items = $items->select('name as text', 'id as value')->get();
             $items = $items->prepend(collect(['text' => '型号规格', 'value' => '']));
             return $this->success(['data' => $items]);
         }

+ 3 - 3
mini/app.json

xqd xqd
@@ -1,12 +1,13 @@
 {
   "pages": [
+    "pages/data/index",
+    "pages/filter-data/index",
+    "pages/data-center/index",
     "pages/index/index",
     "pages/filter/index",
     "pages/add-inner-device/index",
     "pages/project/index",
     "pages/repair/index",
-    "pages/data/index",
-    "pages/data-center/index",
     "pages/create-order/index",
     "pages/create-project-role/index",
     "pages/order-inner/index",
@@ -18,7 +19,6 @@
     "pages/password/index",
     "pages/bind/index",
     "pages/user/index",
-    "pages/filter-data/index",
     "pages/note-detail/index",
     "pages/draft/index",
     "pages/use-record/index",

+ 1 - 2
mini/pages/create-order/index.js

xqd
@@ -331,10 +331,9 @@ Page({
   },
   updateDeviceStat() {
     var devices = this.data.devices
-    var device_total = 0
+    var device_total = devices.length
     var device_money = 0
     for(var i = 0; i < devices.length; ++i) {
-      device_total = device_total + parseInt(devices[i].quantity)
       device_money = device_money + Math.round(parseFloat(devices[i].price) * parseInt(devices[i].quantity) * 100)
     }
     device_money = device_money / 100;

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

xqd
@@ -90,7 +90,7 @@
             </view>
           </view>
           <view class="sg-footer sg-flex sg-align-center sg-space-between sg-margin-top-sm">
-            <view class="sg-font-lg sg-bold">总金额:¥{{item.price * item.quantity / 100}}</view>
+            <view class="sg-font-lg sg-bold">总金额:¥{{item.price * item.quantity}}</view>
             <!-- <view class="sg-btn sg-index-bg sg-pad-sm sg-white" hidden="{{!changePrice}}" bindtap="switchShowPrice"
               data-item="{{item}}" data-show="{{true}}">修改价格</view> -->
           </view>

+ 1 - 1
mini/pages/data-center/index.js

xqd
@@ -329,7 +329,7 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-    this.getTabBar().init();
+    // this.getTabBar().init();
     var filter = wx.getStorageSync('sg-data-filters')
     this.setData({
       filter: filter

+ 24 - 15
mini/pages/data/index.js

xqd xqd xqd
@@ -102,13 +102,13 @@ Page({
     api.getByName(this, 'projects/getAll', 'projects', {});
   },
 
-  updateValue: function(e) {
+  updateValue: function (e) {
     var name = e.currentTarget.dataset.name
     var value = e.currentTarget.dataset.value
     this.setData({
       [name]: value
     })
-    if(name == 'orderBy') {
+    if (name == 'orderBy') {
       this.getChartData()
     }
   },
@@ -125,29 +125,29 @@ Page({
     var that = this
     http({
       url: 'data/getYearAndMonthMoney',
-      data: { 
+      data: {
         date: this.data.date
       },
-      success: function(res) {
-        if(res.code == 0) {
+      success: function (res) {
+        if (res.code == 0) {
           that.setData(res.data)
         }
       }
     })
   },
 
-  getChartData: function() {
+  getChartData: function () {
     var chartIndex = this.data.chartIndex
     var that = this
-    if(chartIndex == 1) {
+    if (chartIndex == 1) {
       http({
         url: 'data/projectStat',
         data: {
           date: this.data.date,
           orderBy: this.data.orderBy
         },
-        success: function(res) {
-          if(res.code == 0) {
+        success: function (res) {
+          if (res.code == 0) {
             that.setData({
               data: res.data
             })
@@ -159,23 +159,32 @@ Page({
   },
   updateChart: function () {
     var data = this.data.data
-    option.xAxis.data = data.names;
     option.legend = {
       data: data.legends
     }
     var chartIndex = this.data.chartIndex
-    if(chartIndex == 1) {
-      option.xAxis.show = true
+    if (chartIndex == 1) {
+      option.xAxis = [{
+        type: 'value'
+      }]
+      option.yAxis = [{
+        type: 'category',
+        axisTick: {
+          show: false
+        },
+        data: data.names
+      }];
       var values = data.values
+      
       option.series = [{
         label: {
-          show: true,
-          position: 'top'
+          show: false
         },
-        name: data.names,
+        name: '租赁费用',
         type: 'bar',
         data: values
       }]
+      // chart.resize({width: '80vw', height: '80vh'})
     }
 
     chart.setOption(option)

+ 3 - 3
mini/pages/data/index.wxml

xqd
@@ -55,10 +55,10 @@
         </van-icon>
       </view>
     </view>
-    <view class="sg-chart sg-flex sg-align-center sg-space-between">
-      <van-icon name="arrow-left" class="sg-icon-lg sg-index-color" hidden="{{chartIndex == 0}}"/>
+    <view class="sg-chart sg-flex sg-align-center sg-justify-center">
+      <!-- <van-icon name="arrow-left" class="sg-icon-lg sg-index-color" hidden="{{chartIndex == 0}}"/> -->
       <ec-canvas id="mychart-dom-bar" canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>
-      <van-icon name="arrow" class="sg-icon-lg sg-index-color"  hidden="{{chartIndex == 2}}"/>
+      <!-- <van-icon name="arrow" class="sg-icon-lg sg-index-color"  hidden="{{chartIndex == 2}}"/> -->
     </view>
   </view>
 </view>

+ 3 - 2
mini/pages/data/index.wxss

xqd
@@ -19,6 +19,7 @@
   margin-bottom: 200rpx;
 }
 .sg-chart {
-  width: 100%;
-  height: 50vh;
+  width: 90vw;
+  height: 70vh;
+  margin-left: 5vw;
 }

+ 31 - 4
mini/pages/filter-data/index.js

xqd xqd xqd xqd
@@ -24,10 +24,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    api.getByName(this, 'devices/get', 'devices', {type: 'drop_menu'});
-    api.getByName(this, 'device-names/get', 'names', {type: 'drop_menu'});
-    api.getByName(this, 'specs/get', 'specs', {type: 'drop_menu'});
-    api.getByName(this, 'rent-types/get', 'rent_types', {type: 'drop_menu'});
+    
   },
 
   onChange: function(e) {
@@ -67,6 +64,7 @@ Page({
     var name = e.currentTarget.dataset.name
     var index = e.currentTarget.dataset.index
     var items = this.data[name]
+    if(index == 0) return false;
     items.splice(index, 1)
     this.setData({
       [name]: items
@@ -89,12 +87,37 @@ Page({
   onDropChange: function(e) {
     var index = e.currentTarget.dataset.index
     var name = e.currentTarget.dataset.name
+
     var val = e.detail
     var items = this.data[name]
     items[index] = val
     this.setData({
       [name]: items
     })
+    if(name == 'device_ids') {
+      this.updateDeviceNames()
+    }
+    if(name == 'device_name_ids') {
+      this.updateSpecs()
+    }
+  },
+
+  updateDeviceNames() {
+    var that = this;
+    that.setData({
+      device_name_ids: ['']
+    })
+    api.getByName(this, 'device-names/get', 'names', {type: 'drop_menu', device_ids: this.data.device_ids}, function() {
+      that.updateSpecs();
+    });
+  },
+
+  updateSpecs() {
+    var that = this;
+    that.setData({
+      spec_ids: ['']
+    })
+    api.getByName(this, 'specs/get', 'specs', {type: 'drop_menu', device_name_ids: this.data.device_name_ids});
   },
 
   /**
@@ -103,6 +126,10 @@ Page({
   onShow: function () {
     var data = wx.getStorageSync('sg-data-filters')
     this.setData(data)
+    api.getByName(this, 'devices/get', 'devices', {type: 'drop_menu'});
+    api.getByName(this, 'device-names/get', 'names', {type: 'drop_menu', device_ids: this.data.device_ids});
+    api.getByName(this, 'specs/get', 'specs', {type: 'drop_menu', device_name_ids: this.data.device_name_ids});
+    api.getByName(this, 'rent-types/get', 'rent_types', {type: 'drop_menu'});
   },
 
   /**

+ 6 - 6
mini/pages/filter-data/index.wxml

xqd xqd xqd
@@ -19,7 +19,7 @@
                   data-name="device_ids" data-index="{{index}}" />
               </van-dropdown-menu>
               <van-button icon="cross" type="danger" color="#1989fa" bindtap="delete" data-name="device_ids"
-                data-index="{{index}}"></van-button>
+                data-index="{{index}}" disabled="{{index == 0}}"></van-button>
             </view>
           </view>
           <view class="sg-margin-tb">
@@ -34,14 +34,14 @@
             <view wx:for="{{device_name_ids}}" wx:key="index" class="sg-flex sg-align-center">
               <van-dropdown-menu class="sg-flex-grow sg-margin-tb-sm sg-margin-right" active-color="#1989fa">
                 <van-dropdown-item value="{{ item }}" options="{{ names }}" bind:change="onDropChange"
-                  data-name="device_name_ids" data-index="{{index}}" />
+                  data-name="device_name_ids" data-index="{{index}}"  disabled="{{ device_ids.length > 1 }}"/>
               </van-dropdown-menu>
               <van-button icon="cross" color="#1989fa" type="danger" bindtap="delete"
-                data-name="device_name_ids" data-index="{{index}}"></van-button>
+                data-name="device_name_ids" data-index="{{index}}" disabled="{{index == 0}}"></van-button>
             </view>
           </view>
           <view class="sg-margin-tb">
-            <van-button type="primary" block icon="plus" color="#1989fa" bindtap="add" data-name="device_name_ids">新增</van-button>
+            <van-button type="primary" block icon="plus" color="#1989fa" bindtap="add" data-name="device_name_ids" disabled="{{ device_ids.length > 1 }}">新增</van-button>
           </view>
         </view>
       </van-tab>
@@ -52,10 +52,10 @@
             <view wx:for="{{spec_ids}}" wx:key="index" class="sg-flex sg-align-center">
               <van-dropdown-menu class="sg-flex-grow sg-margin-tb-sm sg-margin-right" active-color="#1989fa">
                 <van-dropdown-item value="{{ item }}" options="{{ specs }}" bind:change="onDropChange"
-                  data-name="spec_ids" data-index="{{index}}" />
+                  data-name="spec_ids" data-index="{{index}}"  disabled="{{ device_name_ids.length > 1 }}"/>
               </van-dropdown-menu>
               <van-button icon="cross" color="#1989fa" type="danger" bindtap="delete"
-                data-name="spec_ids" data-index="{{index}}"></van-button>
+                data-name="spec_ids" data-index="{{index}}" disabled="{{index == 0}}" disabled="{{ device_name_ids.length > 1 }}"></van-button>
             </view>
           </view>
           <view class="sg-margin-tb">

+ 1 - 4
mini/pages/order-detail/index.js

xqd
@@ -115,12 +115,9 @@ Page({
   },
 
   updateDeviceTotal: function () {
-    var total = 0
     var order = this.data.order
     var devices = order.order_devices ? order.order_devices : []
-    for (var i = 0; i < devices.length; ++i) {
-      total = total + devices[i].quantity
-    }
+    var total = devices.length
     this.setData({
       device_total: total,
       devices: devices

+ 1 - 1
mini/utils/env.js

xqd
@@ -1,3 +1,3 @@
-const isTest = false;
+const isTest = true;
 export const baseUrl = isTest ? 'http://app.rt/api/mini/' : 'http://t18.9026.com/api/mini/';
 export const imgHost = isTest ? 'http://app.rt/images/' : 'http://t18.9026.com/images/'