Prechádzať zdrojové kódy

:sparkles: 增加更换日期

Ritchie 1 rok pred
rodič
commit
e186907702
1 zmenil súbory, kde vykonal 29 pridanie a 0 odobranie
  1. 29 0
      pages/update/update.vue

+ 29 - 0
pages/update/update.vue

@@ -22,6 +22,12 @@
 					<p class="p">扫码</p>
 				</button>
 			</view>
+			<timeSelector showType="date" @btnConfirm="btnConfirm0" @btnCancel="btnCancel0">
+				<view class="body">
+					更换日期:<input type="text" class="input" name="replateDate" :value="replateDate"/>
+				</view>
+			</timeSelector>
+			
 			<view class="body">
 				更换原因:<textarea class="input-two" name="replaceReason" />
 				</view>
@@ -35,12 +41,18 @@
 </template>
 
 <script>
+	import timeSelector from '@/components/wing-time-selector/wing-time-selector.vue';
+	
 	export default {
+		components: {
+			timeSelector
+		},
 		data() {
 			return {
 				machineCoding: '',
 				coding: '',
 				oldCoding: '',
+				replateDate:'',
 				replaceReason: ''
 			}
 		},
@@ -72,12 +84,28 @@
 					    }
 					});
 				},
+				btnConfirm0(e) {
+					console.log('确定时间为:', new Date(e.key));
+					this.replateDate = e.key;
+				},
+				btnCancel0() {
+					this.replateDate = '';
+				},
+				
 				update(event) {
 					var serverUrl = this.serverurl;
 					const {
 						value: modules
 					} = event.detail;
 						var token = uni.getStorageSync("token");
+						var replateDateObject = new Date(this.replateDate);
+						var replateDateString = replateDateObject.getFullYear() + '-' +
+						                            (replateDateObject.getMonth() + 1).toString().padStart(2, '0') + '-' +
+						                            replateDateObject.getDate().toString().padStart(2, '0') + ' ' +
+						                            replateDateObject.getHours().toString().padStart(2, '0') + ':' +
+						                            replateDateObject.getMinutes().toString().padStart(2, '0') + ':' +
+						                            replateDateObject.getSeconds().toString().padStart(2, '0');
+						console.log('时间参数格式化为:', replateDateString);
 						uni.request({
 							url: serverUrl + "/TModules/replace",
 							method: "POST",
@@ -85,6 +113,7 @@
 								"coding":modules.coding,
 								"machineCoding":modules.machineCoding,
 								"oldCoding":modules.oldCoding,
+								"replateDate":replateDateString,
 								"replaceReason":modules.replaceReason,
 								"replacePersonnel":uni.getStorageSync("name"),
 							},