瀏覽代碼

设备绑定逻辑处理

yf_zhb 2 年之前
父節點
當前提交
5091e89f7e
共有 3 個文件被更改,包括 59392 次插入59360 次删除
  1. 48 16
      pages/fourBase/allocation.vue
  2. 59343 59343
      unpackage/dist/dev/app-plus/app-service.js
  3. 1 1
      util/api.js

+ 48 - 16
pages/fourBase/allocation.vue

@@ -14,7 +14,8 @@
 			<view class="bases_search">
 			<view class="bases_search">
 				<view class="bases_search_text">
 				<view class="bases_search_text">
 					<u-icon name="search" class="search" @click="searchs"></u-icon>
 					<u-icon name="search" class="search" @click="searchs"></u-icon>
-					<input type="text" v-model="inputdata" placeholder="请输入设备编号" @change="handleSearch" @confirm="handleSearch" />
+					<input type="text" v-model="inputdata" placeholder="请输入设备编号" @change="handleSearch"
+						@confirm="handleSearch" />
 				</view>
 				</view>
 			</view>
 			</view>
 			<view class="loading" v-if="loadingtf">
 			<view class="loading" v-if="loadingtf">
@@ -101,6 +102,9 @@
 		computed: {
 		computed: {
 			currentType() {
 			currentType() {
 				return this.typeList[this.current]
 				return this.typeList[this.current]
+			},
+			currentEquipmentIDList(){
+				return map(this.selectedGroupByNameIDs[this.currentType.type_name],'device_id') 
 			}
 			}
 		},
 		},
 		methods: {
 		methods: {
@@ -176,7 +180,7 @@
 				this.assignments = this.assignment[0]
 				this.assignments = this.assignment[0]
 				const dataList = res.data[0] && map(res.data[0].children, item => {
 				const dataList = res.data[0] && map(res.data[0].children, item => {
 					return assign({}, item, {
 					return assign({}, item, {
-						check: !!this.selectedDataSource[item.type_name]
+						check: this.currentEquipmentIDList.includes(item.type_name)
 					})
 					})
 				});
 				});
 				this.equipmentList = this.page === 1 ? dataList : concat(this.equipmentList, dataList);
 				this.equipmentList = this.page === 1 ? dataList : concat(this.equipmentList, dataList);
@@ -218,22 +222,13 @@
 				// this.forchange(this.obj)
 				// this.forchange(this.obj)
 			},
 			},
 			checkboxchange(e, items) {
 			checkboxchange(e, items) {
-				console.log(e.detail, 'checkbox ', typeof e.detail.value)
+				console.log(e.detail, 'checkbox ', typeof e.detail.value,items)
 				this.obj[this.assignments.type_name] = JSON.parse(JSON.stringify(e.detail.value))
 				this.obj[this.assignments.type_name] = JSON.parse(JSON.stringify(e.detail.value))
 				const originCurrentTypeIDList = this.selectedGroupByNameIDs[this.currentType.type_name] || []
 				const originCurrentTypeIDList = this.selectedGroupByNameIDs[this.currentType.type_name] || []
-				this.selectedGroupByNameIDs[this.currentType.type_name] = uniqBy(concat(originCurrentTypeIDList, map(e
+				this.selectedGroupByNameIDs[this.currentType.type_name] = map(e
 					.detail.value, id => ({
 					.detail.value, id => ({
 						device_id: id
 						device_id: id
-					}), 'device_id')))
-
-				if (!this.selectedDataSource[e.detail.value]) {
-					this.selectedDataSource[e.detail.value] = {
-						"type_name": this.currentType.type_name,
-						"device_id": e.detail.value
-					}
-				}
-
-
+					}))
 			},
 			},
 			clickLeft() {
 			clickLeft() {
 				uni.navigateBack({
 				uni.navigateBack({
@@ -272,11 +267,24 @@
 				this.page = 1;
 				this.page = 1;
 				this.equipmentList = [];
 				this.equipmentList = [];
 				this.getFourbase();
 				this.getFourbase();
-			}
+			},
+			initEquipmentList() {
+				const result = map(this.bindEquipmentList, item => {
+					return {
+						device_id: item[1],
+						type_name: item[0]
+					};
+				});
+
+				this.selectedDataSource = zipObject(map(result, 'device_id'), result);
+				this.selectedGroupByNameIDs = groupBy(result, item => item.type_name);
+
+				this.getEquipmentList();
+			},
 		},
 		},
 		onLoad(option) {
 		onLoad(option) {
 			this.base_id = option.base_id
 			this.base_id = option.base_id
-			console.log(this.base_id)
+			console.log(this.base_id,'onload ----- equipment list')
 			if (this.base_id) {
 			if (this.base_id) {
 				this.ybase()
 				this.ybase()
 			} else {
 			} else {
@@ -290,6 +298,30 @@
 				this.isTop = false
 				this.isTop = false
 			}
 			}
 		},
 		},
+		onShow() {
+			console.warn('onshow ---------------------- 123')
+			uni.getStorage({
+				key: 'typeid',
+				success: (res) => {
+					var arr = []
+					// for(var key in JSON.parse(res.data)){
+					// 	console.log(key)
+					// 	for(var i=0;i<JSON.parse(res.data)[key].length;i++){
+					// 		var obj={
+					// 			name:key,
+					// 			arr:JSON.parse(res.data)[key][i]
+					// 		}
+					// 		arr.push(obj)
+					// 	}
+					// }
+					console.warn(JSON.parse(res.data), 'get storage typeid  1 all location')
+					// this.baseobj = arr
+				},
+				fail(){
+					console.log('fail')
+				}
+			});
+		},
 		onReachBottom() {
 		onReachBottom() {
 			this.page++;
 			this.page++;
 			this.getFourbase();
 			this.getFourbase();

文件差異過大導致無法顯示
+ 59343 - 59343
unpackage/dist/dev/app-plus/app-service.js


+ 1 - 1
util/api.js

@@ -8,7 +8,7 @@ export const myRequest = (options) => {
 		BASE_URL = process.env.NODE_ENV === 'development' ? "http://114.115.147.140:8002" : "http://8.136.98.49:8002"
 		BASE_URL = process.env.NODE_ENV === 'development' ? "http://114.115.147.140:8002" : "http://8.136.98.49:8002"
 		// BASE_URL = 'http://192.168.1.77:8002'
 		// BASE_URL = 'http://192.168.1.77:8002'
 	}
 	}
-	BASE_URL = 'http://192.168.1.52:8002'
+	// BASE_URL = 'http://192.168.1.52:8002'
 	console.log(BASE_URL,'my request',process.env.NODE_ENV)
 	console.log(BASE_URL,'my request',process.env.NODE_ENV)
 	// console.log(BASE_URL)
 	// console.log(BASE_URL)
 	var session_key = ""
 	var session_key = ""