Browse Source

页面微调

yanjie 4 years ago
parent
commit
d321f8a06d

+ 3 - 0
mini/pages/create-order/index.js

xqd
@@ -331,6 +331,9 @@ Page({
       specIndex: -1,
       rentIndex: -1
     })
+    this.setData({
+      showAdd: false
+    })
     this.updateDeviceStat()
   },
   onClose: function (e) {

+ 44 - 38
mini/pages/create-project-role/index.js

xqd xqd xqd xqd xqd xqd xqd xqd
@@ -25,7 +25,7 @@ Page({
    */
   onLoad: function (options) {
     this.getProjects()
-    if(options.id) {
+    if (options.id) {
       this.setData({
         id: options.id,
         type: 'edit'
@@ -38,13 +38,13 @@ Page({
     this.getRoles()
   },
 
-  updateIndex: function() {
+  updateIndex: function () {
     var project_user = this.data.project_user
-    if(!project_user) return false;
+    if (!project_user) return false;
     var projects = this.data.projects
-    if(projects.length > 0) {
-      for(var i = 0; i < projects.length; ++i) {
-        if(projects[i].id == project_user.project_id) {
+    if (projects.length > 0) {
+      for (var i = 0; i < projects.length; ++i) {
+        if (projects[i].id == project_user.project_id) {
           this.setData({
             projectIndex: i
           })
@@ -53,9 +53,9 @@ Page({
       }
     }
     var roles = this.data.roles
-    if(roles.length > 0) {
-      for(var i = 0; i < roles.length; ++i) {
-        if(roles[i].id == project_user.project_role_id) {
+    if (roles.length > 0) {
+      for (var i = 0; i < roles.length; ++i) {
+        if (roles[i].id == project_user.project_role_id) {
           this.setData({
             roleIndex: i
           })
@@ -72,8 +72,8 @@ Page({
       data: {
         id: this.data.id
       },
-      success: function(res) {
-        if(res.code == 0) {
+      success: function (res) {
+        if (res.code == 0) {
           that.setData({
             project_user: res.data
           })
@@ -85,15 +85,15 @@ Page({
   },
 
   submit() {
-    if(this.data.users.length <= 0) {
+    if (this.data.users.length <= 0) {
       util.error('请选择成员')
       return false
     }
-    if(this.data.projectIndex < 0) {
+    if (this.data.projectIndex < 0) {
       util.error('请选择项目')
       return false
     }
-    if(this.data.roleIndex < 0) {
+    if (this.data.roleIndex < 0) {
       util.error('请选择角色')
       return false
     }
@@ -106,40 +106,45 @@ Page({
       project_id: project_id,
       project_role_id: role_id
     }
-    if(this.data.type == 'edit') {
+    if (this.data.type == 'edit') {
       data.id = this.data.project_user.id
     }
     http({
       url: url,
       data: data,
-      success: function(res) {
-        if(res.code == 0) {
+      success: function (res) {
+        if (res.code == 0) {
           util.success('操作成功')
+          setTimeout(() => {
+            wx.navigateBack({
+              delta: 1,
+            })
+          }, 1000);
         }
       }
     })
   },
 
-  clear: function() {
+  clear: function () {
     this.setData({
       keyword: ''
     })
   },
 
-  blur: function() {
+  blur: function () {
     var that = this
-    setTimeout(function() {
+    setTimeout(function () {
       that.search()
     }, 300)
   },
 
-  search: function() {
+  search: function () {
     var that = this
-    if(!this.data.keyword && this.data.type == 'create') return false;
+    if (!this.data.keyword && this.data.type == 'create') return false;
     var data = {
       keyword: this.data.keyword
     }
-    if(this.data.type == 'edit') {
+    if (this.data.type == 'edit') {
       data = {
         keyword: this.data.keyword,
         id: this.data.project_user.user_id
@@ -149,9 +154,9 @@ Page({
     http({
       url: 'users/search',
       data: data,
-      success: function(res) {
-        if(res.code == 0) {
-          if(res.data.length <= 0) {
+      success: function (res) {
+        if (res.code == 0) {
+          if (res.data.length <= 0) {
             util.error('未找到相应用户')
           }
           that.setData({
@@ -163,57 +168,58 @@ Page({
     })
   },
 
-  bindPickerChange: function(e) {
+  bindPickerChange: function (e) {
     var name = e.currentTarget.dataset.name
     this.setData({
       [name]: e.detail.value
     })
   },
 
-  getRoles: function() {
+  getRoles: function () {
     var that = this
     http({
       url: 'project-roles/getByExclude',
       data: {
         id: this.data.id
       },
-      success: function(res) {
-        if(res.code == 0) {
+      success: function (res) {
+        if (res.code == 0) {
           that.setData({
             roles: res.data
           })
-          if(that.data.type == 'edit') that.updateIndex()
+          if (that.data.type == 'edit') that.updateIndex()
         }
       }
     })
   },
 
-  getProjects: function() {
+  getProjects: function () {
     var that = this
     var users = this.data.users
     var user_id = ''
-    if(users.length > 0) {
+    if (users.length > 0) {
       user_id = users[0].id
     }
     http({
       url: 'projects/getAll',
       data: {
         user_id: user_id,
-        self: true
+        self: true,
+        type: that.data.type
       },
-      success: function(res) {
-        if(res.code == 0) {
+      success: function (res) {
+        if (res.code == 0) {
           that.setData({
             projects: res.data,
             projectIndex: -1
           })
-          if(that.data.type == 'edit') that.updateIndex()
+          if (that.data.type == 'edit') that.updateIndex()
         }
       }
     })
   },
 
-  updateInput: function(e) {
+  updateInput: function (e) {
     var name = e.currentTarget.dataset.name
     this.setData({
       [name]: e.detail.value

+ 2 - 2
mini/pages/create-project-role/index.wxml

xqd
@@ -31,8 +31,8 @@
   </view>
   <view class="sg-pick-box">
     <view class="sg-pick-item sg-pad">
-      <view class="sg-pick-name">将他添加到:</view>
-      <picker bindchange="bindPickerChange" value="{{projectIndex}}" range="{{projects}}" range-key="name"
+      <view class="sg-pick-name">{{type!='edit'?'将他添加到:':'当前所属项目:'}}</view>
+      <picker bindchange="bindPickerChange" disabled="{{type=='edit'}}" value="{{projectIndex}}" range="{{projects}}" range-key="name"
         data-name="projectIndex">
         <view class="picker sg-gray-color">
           {{projectIndex >= 0 ? projects[projectIndex].name : '请选择添加项目'}}

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

xqd
@@ -2,7 +2,7 @@
 <view class="sg-container">
   <view class="sg-top-box sg-fix-top sg-white-bg">
     <view class="sg-search-box sg-flex sg-align-center">
-      <van-dropdown-menu>
+      <van-dropdown-menu active-color="#5992fd">
         <van-dropdown-item value="{{ work_point_id }}" options="{{ work_points }}" bind:change="onDropChange" data-name="work_point_id"/>
       </van-dropdown-menu>
       <van-search value="{{ keyword }}" placeholder="请输入订单号或提交人搜索" use-right-icon-slot class="sg-flex-grow" left-icon="none" bind:change="onDropChange" data-name="keyword">

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

xqd xqd xqd xqd xqd xqd xqd
@@ -20,12 +20,12 @@ Page({
     topRole: null
   },
   //事件处理函数
-  bindViewTap: function() {
+  bindViewTap: function () {
     wx.navigateTo({
       url: '../logs/logs'
     })
   },
-  onShow: function() {
+  onShow: function () {
     this.getTabBar().init();
     this.setData({
       list: []
@@ -33,15 +33,15 @@ Page({
     this.search();
     api.getByName(this, 'notifications/notReadCount', 'notReadCount');
     var that = this;
-    api.getByName(this, 'users/getTopRole', 'topRole', {}, function(res) {
+    api.getByName(this, 'users/getTopRole', 'topRole', {}, function (res) {
       var role = that.data.topRole
-      if(role && role.key == 'leader') {
+      if (role && role.key == 'leader') {
         wx.switchTab({
           url: '/pages/account/index',
         })
       }
     });
-    api.getByName(this, 'getUserInfo', 'userInfo', {}, function(res) {
+    api.getByName(this, 'getUserInfo', 'userInfo', {}, function (res) {
       app.updateUserInfo(res);
       that.getTabBar().init();
     });
@@ -52,7 +52,7 @@ Page({
         userInfo: app.globalData.userInfo,
         hasUserInfo: true
       })
-    } else if (this.data.canIUse){
+    } else if (this.data.canIUse) {
       // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
       // 所以此处加入 callback 以防止这种情况
       app.userInfoReadyCallback = res => {
@@ -74,26 +74,26 @@ Page({
       })
     }
   },
-  navigate: function(e) {
+  navigate: function (e) {
     var url = e.currentTarget.dataset.url
     wx.navigateTo({
       url: url,
     })
   },
-  updateInput: function(e) {
+  updateInput: function (e) {
     var name = e.currentTarget.dataset.name
     this.setData({
       [name]: e.detail.value
     })
   },
-  search: function() {
+  search: function () {
     this.setData({
       list: [],
       page: 1
     })
     this.getList()
   },
-  getList: function() {
+  getList: function () {
     // if(this.data.touchBottom) return false;
 
     var that = this
@@ -103,8 +103,8 @@ Page({
         page: this.data.page,
         name: this.data.keyword
       },
-      success: function(res) {
-        if(res.code == 0) {
+      success: function (res) {
+        if (res.code == 0) {
           var list = that.data.list.concat(res.data)
           that.setData({
             touchBottom: res.data.length == 0,
@@ -114,7 +114,7 @@ Page({
       }
     })
   },
-  getUserInfo: function(e) {
+  getUserInfo: function (e) {
     console.log(e)
     app.globalData.userInfo = e.detail.userInfo
     this.setData({
@@ -122,8 +122,8 @@ Page({
       hasUserInfo: true
     })
   },
-  onReachBottom: function() {
-    if(!this.data.touchBottom) {
+  onReachBottom: function () {
+    if (!this.data.touchBottom) {
       this.setData({
         page: this.data.page + 1
       })

+ 3 - 0
mini/pages/order-detail-inner/index.js

xqd xqd
@@ -140,6 +140,8 @@ Page({
     })
       .then(() => {
         that.submitCheck(e)
+      }).catch(()=>{
+        Dialog.close()
       })
   },
   submitCheck: function (e) {
@@ -154,6 +156,7 @@ Page({
       },
       success: function (res) {
         if (res.code == 0) {
+          Dialog.close()
           util.success('操作成功')
           setTimeout(function() {
             that.init()

+ 3 - 0
mini/pages/order-detail/index.js

xqd xqd
@@ -142,6 +142,8 @@ Page({
     })
       .then(() => {
         that.submitCheck(e)
+      }).catch(()=>{
+        Dialog.close()
       })
   },
   submitCheck: function (e) {
@@ -156,6 +158,7 @@ Page({
       },
       success: function (res) {
         if (res.code == 0) {
+          Dialog.close()
           util.success('操作成功')
           setTimeout(function() {
             that.init()

+ 1 - 0
mini/utils/util.js

xqd
@@ -40,6 +40,7 @@ const error = msg => {
 const success = msg => {
   wx.showToast({
     title: msg,
+    duration:1000
   })
 }