miaofuhao преди 3 години
родител
ревизия
f8ae95bec6
променени са 2 файла, в които са добавени 58 реда и са изтрити 9 реда
  1. 6 5
      CallCenterWeb.UI/RMYYAPP/pages/setting/personDetail/personDetail.vue
  2. 52 4
      CallCenterWeb.UI/RMYYAPP/utils/helper.js

+ 6 - 5
CallCenterWeb.UI/RMYYAPP/pages/setting/personDetail/personDetail.vue

@@ -31,7 +31,7 @@
31 31
 					</uni-forms-item>
32 32
 					
33 33
 				</uni-forms>
34
-				<button type="primary" @click="formSubmit('valiForm')" class="btn">提交</button>
34
+				<button type="primary" :disabled="disabledButton" @click="formSubmit('valiForm')" class="btn">提交</button>
35 35
 			</view>
36 36
 		</view>
37 37
 	</view>
@@ -57,6 +57,7 @@
57 57
 					Remark:''	//个性签名  dataTree
58 58
 				},
59 59
 				F_DeptName: '1_1',
60
+				disabledButton:false,
60 61
 				detailUserData:{},
61 62
 				roleOptions:[],
62 63
 				deptDataTree:[], 
@@ -79,7 +80,6 @@
79 80
 			this.getUserAccount(option.userCode)
80 81
 			// this.getDet()
81 82
 			
82
-			
83 83
 		},
84 84
 		methods: {
85 85
 			changeRoleId() {},
@@ -105,9 +105,7 @@
105 105
 							} else{
106 106
 								this.formData.gender = '1'
107 107
 							}
108
-							console.log(this.roleOptions)
109 108
 							this.roleOptions.forEach(v =>{
110
-								console.log(v)
111 109
 								if(v.value == res.data.F_RoleId) {
112 110
 									this.formData.RoleName = v.text
113 111
 								}
@@ -118,7 +116,9 @@
118 116
 					}
119 117
 				})
120 118
 			},
119
+			
121 120
 			formSubmit(){
121
+				this.disabledButton = true
122 122
 				const params = {
123 123
 					IsSeat:this.formData.IsSeat,
124 124
 				  userid: this.formData.userid,
@@ -130,8 +130,9 @@
130 130
 				  Phon: this.formData.Phon, // 0保存,1保存并提交
131 131
 				  Remark: this.formData.Remark// 工单内容
132 132
 				}
133
-				this.$mHelper.httpPost("UserAccount/EditUsers",params,1)
133
+				this.$mHelper.httpPost("UserAccount/EditUsers",params,1,res=>this.disabledButton=res)
134 134
 			},
135
+			
135 136
 			//	角色下拉	Role/GetList
136 137
 			getRoleList(){
137 138
 				const params = {

+ 52 - 4
CallCenterWeb.UI/RMYYAPP/utils/helper.js

@@ -22,7 +22,10 @@ export default {
22 22
 			icon
23 23
 		});
24 24
 	},
25
-	httpPost(url, params, index) {
25
+	httpPost(url, params, delta,fn) {
26
+		
27
+		uni.showLoading({title: '加载中'})
28
+
26 29
 		http.post(url, params).then((res) => {
27 30
 			if (res.state.toLowerCase() === "success") {
28 31
 				uni.hideLoading()
@@ -32,10 +35,12 @@ export default {
32 35
 				});
33 36
 				setTimeout(() => {
34 37
 					uni.$emit("updateList", {}); //列表刷新数据
35
-					uni.navigateBack({
36
-						delta: index,
37
-					})
38
+					uni.navigateBack({delta})
39
+					fn(false)
38 40
 				}, 500)
41
+				
42
+			}else{
43
+				fn(false)
39 44
 			}
40 45
 		})
41 46
 
@@ -66,6 +71,49 @@ export default {
66 71
 				imgIdListToString.substring(0, imgIdListToString.length - 1) : imgIdListToString;
67 72
 			return imgid
68 73
 		},
74
+	// 防抖
75
+	// 例子 debounceList = debounce(getList, 5000)先声明
76
+	// 后debounceList()调用,每个页面声明一次即可,调用可多次	
77
+	debounce(fn, delay=3000, immediate = false,  resultCallback) {
78
+	  // 1.定义一个定时器, 保存上一次的定时器
79
+	  let timer = null
80
+	  let isInvoke = false
81
+		
82
+	  // 2.真正执行的函数
83
+	  const _debounce = function(...args) {
84
+	    return new Promise((resolve, reject) => {
85
+	      // 取消上一次的定时器
86
+	      if (timer) clearTimeout(timer)
87
+	
88
+	      // 判断是否需要立即执行
89
+	      if (immediate && !isInvoke) {
90
+	        const result = fn.apply(this, args)
91
+	        if (resultCallback) resultCallback(result)
92
+	        resolve(result)
93
+	        isInvoke = true
94
+	      } else {
95
+	        // 延迟执行
96
+	        timer = setTimeout(() => {
97
+	          // 外部传入的真正要执行的函数
98
+	          const result = fn.apply(this, args)
99
+	          if (resultCallback) resultCallback(result)
100
+	          resolve(result)
101
+	          isInvoke = false
102
+	          timer = null
103
+	        }, delay)
104
+	      }
105
+	    })
106
+	  }
107
+	
108
+	  // 封装取消功能
109
+	  _debounce.cancel = function() {
110
+	    if (timer) clearTimeout(timer)
111
+	    timer = null
112
+	    isInvoke = false
113
+	  }
114
+	
115
+	  return _debounce
116
+	},
69 117
 	// 通过子级部门id获取父级
70 118
 	callback(treeData, id){
71 119
 		for (let i = 0; i < treeData.length; i++) {