hsb пре 6 месеци
родитељ
комит
6c01de6178
5 измењених фајлова са 100 додато и 81 уклоњено
  1. 4 2
      components/popup-select/index.vue
  2. 2 1
      manifest.json
  3. 19 15
      pages/home/home.vue
  4. 72 62
      pages/other/addOrder.vue
  5. 3 1
      utils/config.js

+ 4 - 2
components/popup-select/index.vue

@@ -3,7 +3,7 @@
       showToolbar
       showToolbar
       :show="showPicker"
       :show="showPicker"
       :immediateChange='true'
       :immediateChange='true'
-      :columns="[options.length?options:option]"
+      :columns="[options?options:option]"
       keyName='text'
       keyName='text'
       :cancelText="$t('settings.cancelText')"
       :cancelText="$t('settings.cancelText')"
       :confirmText="$t('settings.confirmText')"
       :confirmText="$t('settings.confirmText')"
@@ -32,7 +32,7 @@ export default {
     return {
     return {
       showPicker:false,
       showPicker:false,
       searchText:'',
       searchText:'',
-      options:[],
+      options:null,
     }
     }
   },
   },
   props:{
   props:{
@@ -63,6 +63,8 @@ export default {
             arr.push(item)
             arr.push(item)
           }
           }
         })
         })
+        console.log(arr);
+        
         this.options=arr
         this.options=arr
       }else{
       }else{
         this.options=JSON.parse(JSON.stringify(this.option))
         this.options=JSON.parse(JSON.stringify(this.option))

+ 2 - 1
manifest.json

@@ -144,7 +144,8 @@
                 "/" : {
                 "/" : {
                     // "target" : "https://saas.createtobest.com",
                     // "target" : "https://saas.createtobest.com",
                     // "target" : "http://192.168.124.23:3789",
                     // "target" : "http://192.168.124.23:3789",
-                    "target" : "http://192.168.124.27:3789",
+                    // "target" : "http://192.168.124.27:3789",
+                    "target" : "https://app.keysoft666.com",
                     // "target" : "http://localhost:9999",
                     // "target" : "http://localhost:9999",
                     // "target" : "http://localhost:9999",
                     // "target" : "http://localhost:9999",
                     // "target" : "http://localhost:3789",
                     // "target" : "http://localhost:3789",

+ 19 - 15
pages/home/home.vue

@@ -26,7 +26,7 @@
 					</view>
 					</view>
 					<view class="status-card">
 					<view class="status-card">
 						<view class="label">已装数</view>
 						<view class="label">已装数</view>
-						<view class="value highlight">{{ currentData.hasNumber || '0' }}</view>
+						<view class="value highlight">{{ currentData.hasNum || '0' }}</view>
 					</view>
 					</view>
 				</view>
 				</view>
 			</view>
 			</view>
@@ -93,6 +93,7 @@
 		data() {
 		data() {
 			return {
 			return {
 				ws:null,
 				ws:null,
+				wsUrl:'',
 				currentData:{},
 				currentData:{},
 				orders:[],
 				orders:[],
 				currentLane:{
 				currentLane:{
@@ -114,7 +115,7 @@
 		onLoad(options) {
 		onLoad(options) {
 			uni.hideTabBar()
 			uni.hideTabBar()
 			this.getLaneList()
 			this.getLaneList()
-			this.connectSocket()
+			// this.connectSocket()
 		},
 		},
 		beforeUnmount() {
 		beforeUnmount() {
 			this.ws.close(); // 组件销毁前关闭连接
 			this.ws.close(); // 组件销毁前关闭连接
@@ -122,8 +123,13 @@
 		methods: {
 		methods: {
 			//连接车道ws
 			//连接车道ws
 			connectSocket(){
 			connectSocket(){
+				console.log(this.wsUrl);
+				if(!this.wsUrl) return
+				if(this.ws){
+					this.ws.close(); // 组件销毁前关闭连接
+				}
 				// 创建 WebSocket 连接(替换为你的服务端地址)
 				// 创建 WebSocket 连接(替换为你的服务端地址)
-				this.ws = new WebSocket('ws://192.168.124.27:5559');
+				this.ws = new WebSocket(this.wsUrl);
 
 
 				// 监听连接成功
 				// 监听连接成功
 				this.ws.onopen = () => {
 				this.ws.onopen = () => {
@@ -132,7 +138,8 @@
 
 
 				// 监听消息接收
 				// 监听消息接收
 				this.ws.onmessage = (event) => {
 				this.ws.onmessage = (event) => {
-					console.log('1111111111111111111',JSON.parse(event.data));
+					console.log('1111111111111111',event);
+					
 					this.currentData = JSON.parse(event.data)
 					this.currentData = JSON.parse(event.data)
 				};
 				};
 
 
@@ -147,15 +154,7 @@
 					setTimeout(() => this.connectSocket(), 3000); // 3秒后重连
 					setTimeout(() => this.connectSocket(), 3000); // 3秒后重连
 				};
 				};
 			},
 			},
-			sendMessage() {
-				if (this.ws.readyState === WebSocket.OPEN) {
-					console.log('1111111111111111111',this.currentLane.id);
-					this.ws.send(this.currentLane.id);
-				}else{
-					setTimeout(()=>this.sendMessage(),2000)
-					
-				}
-			},
+		
 			//去新增订单
 			//去新增订单
 			toAdd(){
 			toAdd(){
 				uni.navigateTo({ url: '/pages/other/addOrder' })
 				uni.navigateTo({ url: '/pages/other/addOrder' })
@@ -178,7 +177,8 @@
 						if(this.laneOption.length){
 						if(this.laneOption.length){
 							this.currentLane.name = this.laneOption[0].text
 							this.currentLane.name = this.laneOption[0].text
 							this.currentLane.id = this.laneOption[0].value
 							this.currentLane.id = this.laneOption[0].value
-							this.sendMessage()
+							this.wsUrl = this.laneOption[0].monitorAddress
+							this.connectSocket()
 						}
 						}
 					}
 					}
 				})
 				})
@@ -197,9 +197,13 @@
 			},
 			},
 			//车道确定
 			//车道确定
 			onConfirm(value) {
 			onConfirm(value) {
-				if (value.value) {
+				console.log(value);
+				
+				if (value.value && value.value !== this.currentLane.id) {
 					this.currentLane.name = value.text
 					this.currentLane.name = value.text
 					this.currentLane.id = value.value
 					this.currentLane.id = value.value
+					this.wsUrl = value.monitorAddress
+					this.connectSocket()
 				}
 				}
 			},
 			},
 		}
 		}

+ 72 - 62
pages/other/addOrder.vue

@@ -14,7 +14,7 @@
 					>
 					>
 					<u-input readonly v-model="orderForm.materialName" border="none"
 					<u-input readonly v-model="orderForm.materialName" border="none"
 						placeholder="请选择品种"/>
 						placeholder="请选择品种"/>
-						<view slot="right" @click.stop="addMater">
+						<view slot="right" @click.stop="addOpen(true)">
 							<u-button
 							<u-button
 								type="primary"
 								type="primary"
 								size="mini"
 								size="mini"
@@ -26,7 +26,7 @@
 				<u-form-item label="客户" borderBottom prop="companyId" @click="showPopup('popupCompany')">
 				<u-form-item label="客户" borderBottom prop="companyId" @click="showPopup('popupCompany')">
 					<u-input readonly v-model="orderForm.companyName" border="none"
 					<u-input readonly v-model="orderForm.companyName" border="none"
 						placeholder="请选择客户"/>
 						placeholder="请选择客户"/>
-						<view slot="right" @click.stop="addCompany">
+						<view slot="right" @click.stop="addOpen(false)">
 							<u-button
 							<u-button
 								
 								
 								type="primary"
 								type="primary"
@@ -59,6 +59,11 @@
 		<CarKeyboard :show.sync="carKeyboardShow" :isProvince="false" :vehicleNo="orderForm.vehicle"
 		<CarKeyboard :show.sync="carKeyboardShow" :isProvince="false" :vehicleNo="orderForm.vehicle"
 			@confirm="carConfirm" vehicleType="car">
 			@confirm="carConfirm" vehicleType="car">
 		</CarKeyboard>
 		</CarKeyboard>
+		<u-modal @confirm="addConfirm" @cancel="addCancel" :show="addShow" :showCancelButton="true" :closeOnClickOverlay="true" :title="addTitle">
+			<view class="add-input" slot="default">
+				<u-input type="text" v-model="keyName" placeholder="请输入名称"/>
+			</view>
+		</u-modal>
 	</view>
 	</view>
 </template>
 </template>
 
 
@@ -84,6 +89,9 @@
 			return {
 			return {
 				carKeyboardShow: false,
 				carKeyboardShow: false,
 				start: dayjs().format('YYYY-MM-DD'),
 				start: dayjs().format('YYYY-MM-DD'),
+				addShow: false,
+				addTitle:"",
+				keyName:"",
 				orderForm: {
 				orderForm: {
 					roadId: '',
 					roadId: '',
 					roadName: '',
 					roadName: '',
@@ -112,69 +120,68 @@
 			showPopup(refs) {
 			showPopup(refs) {
 				this.$refs[refs].showPicker = true
 				this.$refs[refs].showPicker = true
 			},
 			},
-			//新增物料
-			addMater(e){
-				console.log(e);
-				
-				let that = this
-				uni.showModal({
-					title: '新增品种',
-					editable:true,
-					showCancel: true,
-					placeholderText:'请输入品种名称',
-					success: ({ confirm, cancel , content}) => {
-						if(confirm){
-							uni.showLoading({
-								title: '保存中',
-								mask:true,
-							});
-							saveMaterial({name:content}).then(res=>{
-								if(res.statusCode == '200'){
-									uni.showToast({
-										title: '保存成功',
-										icon: 'none',
-										mask: true
-									})
-									that.getMater()
-								}
-								uni.hideLoading();
-							}).finally(()=>{
-									uni.hideLoading();
-							});
-						}
-					}
-				})
+			//新增
+			addOpen(boo){
+				this.addShow = true
+				this.addType = boo
+				if(boo){
+					this.addTitle = "新增品种"
+				}else{
+					this.addTitle = "新增客户"
+				}
 			},
 			},
-			//新增客户
-			addCompany(){
+			addCancel(){
+				this.addShow = false
+				this.keyName = ''
+			},
+			//新增
+			addConfirm(){
 				let that = this
 				let that = this
-				uni.showModal({
-					title: '新增客户',
-					editable:true,
-					showCancel: true,
-					placeholderText:'请输入客户名称',
-					success: ({ confirm, cancel , content}) => {
-						if(confirm){
-							uni.showLoading({
-								title: '保存中',
-								mask:true,
-							});
-							saveCompany({name:content}).then(res=>{
-								if(res.statusCode == '200'){
-									uni.showToast({
-										title: '保存成功',
-										icon: 'none',
-										mask: true
-									})
-									that.getCompany()
-								}
-								uni.hideLoading();
-							}).finally(()=>{
-									uni.hideLoading();
-							});
+				if(!that.keyName){
+					uni.showToast({
+						title: '请输入名称',
+						icon: 'none',
+						mask: true
+					})
+					return
+				}
+				uni.showLoading({
+					title: '保存中',
+					mask:true,
+				});
+				if(this.addType){
+					saveMaterial({name:that.keyName}).then(res=>{
+						if(res.statusCode == '200'){
+							uni.showToast({
+								title: '保存成功',
+								icon: 'none',
+								mask: true
+							})
+							that.addShow = false
+							that.keyName = ''
+							that.getMater()
 						}
 						}
-					}
-				})
+						uni.hideLoading();
+					}).finally(()=>{
+							uni.hideLoading();
+					});
+				}else{
+					saveCompany({name:that.keyName}).then(res=>{
+						if(res.statusCode == '200'){
+							uni.showToast({
+								title: '保存成功',
+								icon: 'none',
+								mask: true
+							})
+							that.addShow = false
+							that.keyName = ''
+							that.getCompany()
+						}
+						uni.hideLoading();
+					}).finally(()=>{
+							uni.hideLoading();
+					});
+				}
 			},
 			},
 			//获取客户
 			//获取客户
 			getCompany(){
 			getCompany(){
@@ -344,6 +351,9 @@
 			padding: 0 32rpx;
 			padding: 0 32rpx;
 		}
 		}
 	}
 	}
+	.add-input{
+		width: 100%;
+	}
 
 
 	// button {
 	// button {
 	// 	// background:linear-gradient(to right,#4680F9 0%,#00e2fa 80%,#00e2fa 100%);
 	// 	// background:linear-gradient(to right,#4680F9 0%,#00e2fa 80%,#00e2fa 100%);

+ 3 - 1
utils/config.js

@@ -1,3 +1,5 @@
-let publicUrl="http://192.168.124.27:3789" 
+// let publicUrl="http://192.168.124.27:3789" 
+let publicUrl="https://app.keysoft666.com" 
+
 
 
 export {publicUrl}
 export {publicUrl}