Explorar o código

权限新增,修改,站点筛选下拉,做搜素功能,完善开发

Ming %!s(int64=3) %!d(string=hai) anos
pai
achega
8a23b0dfbd
Modificáronse 3 ficheiros con 55 adicións e 38 borrados
  1. 52 35
      pages/authAdd/authAdd.vue
  2. 1 1
      pages/index/components/chart/chart.vue
  3. 2 2
      util/api.js

+ 52 - 35
pages/authAdd/authAdd.vue

@@ -83,12 +83,12 @@
 					站点:
 				</view>
 				<view style="position:relative" class="innerZd">
-					<input name="siteName" v-model="authorityData.siteName" @click="test" @focus="focusfns" @input="handleInput()"
+					<input name="siteName" v-model="authorityData.siteName" @click="test" @focus="focusfns" @input="handleInputEdit()"
 					 placeholder="请输入或选择"></input>
 		
 					<view class="siteItems" v-if="isShow" style="max-height:60vh;overflow:auto">
-						<view class=" site-item" v-if="!siteItemData.length">暂无结果</view>
-		
+						<view class=" site-item" v-if="!siteItemData.length">暂无结果</view>
+						
 						<view class="site-item" v-for="(item,index) in siteItemData" @click="add(item,index)" :key="index">{{item.siteName}}</view>
 					</view>
 					<view style="width:500rpx;max-height:30vh;overflow:scroll" class="selectedBox">
@@ -99,8 +99,6 @@
 		
 					</view>
 				</view>
-		
-		
 			</view>
 		
 			<view class="form-item margin-top">
@@ -146,12 +144,10 @@
 					"longitude": "",
 					"dimension": "",
 					"contactor": "",
-					"mobile": "",
-					
-					
-					
+					"mobile": "",
 				},
-
+				
+		
 				// 站点多选下拉
 				siteItemDataOrigin: [],
 				selectedData: [],
@@ -185,14 +181,27 @@
 				});
 			}
 			this.getSiteList();
-			this.getphoneList()
-			
-			
-			
-
+			this.getphoneList();
+			this.siteItemData = this.getNotSelectItem();
+		
 
 		},
-		methods: {
+		methods: {
+			
+			 unique(arr){        
+				 // alert(1)
+			        for(var i=0; i<arr.length; i++){
+			            for(var j=i+1; j<arr.length; j++){
+			                if(arr[i]==arr[j]){         //第一个等同于第二个,splice方法删除第二个
+			                    arr.splice(j,1);
+			                    j--;
+			                }
+			            }
+			        }
+			return arr;
+			},
+			
+			
 			
 			//修改提交
 			editSbuimt(){
@@ -210,8 +219,6 @@
 					});
 					return
 				}
-				console.log('this.selectedData')
-				console.log(this.selectedData)
 				this.selectedString = this.selectedArr.toString();
 				this.setEditAuthority({
 					"phone": this.authorityData.phone,
@@ -255,9 +262,10 @@
 					data:params
 				})
 				this.authorityData=res.data.data[0]
-				this.selectedData=res.data.data[0].siteIdData
+				this.selectedData=res.data.data[0].siteIdData;				
+			
+			},
 			
-			},
 			
 			
 			radioChange(e) {
@@ -328,10 +336,10 @@
 					url: 'SiteManagement/getSiteList',
 				})
 				this.siteItemData = res.data.data;
-				this.siteItemDataOrigin = res.data.data;
+				this.siteItemDataOrigin = res.data.data;
+				this.siteItemData = this.getNotSelectItem();
 				
 			},
-			
 			
 			addAuthority(params = {}) {
 				return this.$myRequest({
@@ -341,20 +349,22 @@
 			},
 
 			add: function(item, index) {
-				this.selectedData.push(item);
-				console.log('1111')
-				console.log(this.selectedData)	
+				this.selectedData.push(item);
 				this.isShow = false;
 				this.formMess.siteName = '';
+				this.authorityData.siteName = '';
 				this.siteItemData.splice(index, 1);
+				this.unique(this.siteItemData)
 
 			},
 			deleteItem: function(item, index) {
 				this.selectedData.splice(index, 1);
 				this.siteItemDataOrigin.push(item);
+				
 				//将元素根据搜索内容过滤出来  这里改变了siteItemData
 				this.siteItemData = this.getNotSelectItem();
 				this.siteItemData = this.siteItemData.filter(item => item.siteName.indexOf(this.formMess.siteName) > -1);
+				this.unique(this.siteItemData)
 			},
 
 			// 站点多选下拉
@@ -364,28 +374,35 @@
 			test2: function() {
 				this.isShow = false;
 			},
+			//权限新增下拉筛选
 			handleInput() {
 				//将元素根据搜索内容过滤出来  这里改变了siteItemData
 				this.siteItemData = this.getNotSelectItem();
 				this.siteItemData = this.siteItemData.filter(item => item.siteName.indexOf(this.formMess.siteName) > -1);
-
+				this.unique(this.siteItemData)
+			},
+			//权限修改下拉筛选
+			handleInputEdit() {
+				//将元素根据搜索内容过滤出来  这里改变了siteItemData
+				this.siteItemData = this.getNotSelectItem();
+				this.siteItemData = this.siteItemData.filter(item => item.siteName.indexOf(this.authorityData.siteName) > -1);
+				this.unique(this.siteItemData)
 			},
+			
+			
 			// 站点多选下拉 end
 
 			getNotSelectItem() {
-
 				let ok1 = this.siteItemDataOrigin;
 				let ok2 = this.selectedData;
-
 				if (ok2.length) {
 					for (let i = 0; i < ok2.length; i++) {
 						for (let j = 0; j < ok1.length; j++) {
-							if (ok1[j] === ok2[i]) { //值已经被选中
+							if (ok1[j].id == ok2[i].id) { //值已经被选中
 								ok1.splice(j, 1);
 							}
 						}
 					}
-
 				}
 				return ok1;
 			},
@@ -422,15 +439,15 @@
 			},
 			focusfns: function(e) {
 				// this.getNotSelectItem();
-
 				//将元素根据搜索内容过滤出来  这里改变了siteItemData
-
 				this.siteItemData = this.getNotSelectItem();
-
-
 				this.siteItemData = this.siteItemData.filter(item => item.siteName.indexOf(this.formMess.siteName) > -1);
+				this.unique(this.siteItemData)
 			},
-
+		
+			
+			
+			
 
 
 

+ 1 - 1
pages/index/components/chart/chart.vue

@@ -39,7 +39,7 @@
 						position: ['50%', '50%']
 					},
 					title: [{ //aa标题
-						text: '{val|' + this.bindData.integratedAlarmCount + '}\n{name|' + title + '}',
+						text: '{val|' + this.bindData.alarmCount + '}\n{name|' + title + '}',
 						top: '45%',
 						left: 'center',
 						textStyle: {

+ 2 - 2
util/api.js

@@ -1,5 +1,5 @@
-const BASE_URL = 'https://iot.usky.cn/USKYOF/USKYOF.php/Home/' //(测试域名)
-// const BASE_URL='https://qhome.usky.cn/USKYOF/USKYOF.php/Home/'
+// const BASE_URL = 'https://iot.usky.cn/USKYOF/USKYOF.php/Home/' //(测试域名)
+const BASE_URL='https://qhome.usky.cn/USKYOF/USKYOF.php/Home/'
 // 同时发送异步代码的次数,防止一次点击中有多次请求,用于处理
 let ajaxTimes = 0;