From fbbbc66329808249c7a0689f2efca6c79a6bf892 Mon Sep 17 00:00:00 2001 From: lty <876263681@qq.com> Date: 星期四, 28 八月 2025 08:37:11 +0800 Subject: [PATCH] # --- pages/basics/matQuery.vue | 334 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 267 insertions(+), 67 deletions(-) diff --git a/pages/basics/matQuery.vue b/pages/basics/matQuery.vue index bdfe3bd..15150f0 100644 --- a/pages/basics/matQuery.vue +++ b/pages/basics/matQuery.vue @@ -3,11 +3,11 @@ <view> <view class="container"> <view class="text-box"> - <view class="text-title"><text>鍟嗗搧缂栫爜</text></view> + <view class="text-title"><text>鐗╂枡鍙�</text></view> <view class="text-title"><text>{{matData.matnr}}</text></view> </view> <view class="text-box"> - <view class="text-title"><text>鍟嗗搧鍚嶇О</text></view> + <view class="text-title"><text>鐗╂枡鍚�</text></view> <view class="text-title">{{matData.maktx}}</view> </view> <view class="text-box"> @@ -19,10 +19,46 @@ <view class="text-title"><input type="text" v-model="matData.batch"></view> </view> <view class="text-box"> + <view class="text-title"> + <text style="font-size: 24rpx;">灞炴��</text> + </view> + + <view class="attr-row"> + <picker + :range="commonProps" + :value="selectedIndex" + @change="onPropChange" + class="half-box" + > + <view class="picker-box"> + <text>{{ matData.proType || '璇烽�夋嫨灞炴��' }}</text> + </view> + </picker> + + <input + type="text" + v-model="matData.proType" + placeholder="鎵嬪姩杈撳叆鍏朵粬灞炴��" + class="half-box" + /> + + </view> + </view> + + + <view class="text-box"> + <view class="text-title"><text>瀹㈡埛鍥惧彿</text></view> + <view class="text-title"><input type="text" v-model="matData.temp2"></view> + </view> + <view class="text-box"> + <view class="text-title"><text>鍚堝悓鍙�</text></view> + <view class="text-title"><input type="text" v-model="matData.outOrderNo"></view> + </view> + <view class="text-box"> <view class="text-title"><text>鏁伴噺</text></view> <view class="text-title"> <view> - <uni-number-box v-model="matData.anfme" :max="9999" color="#747474" @change="changeValue"/> + <uni-number-box :value="matData.anfme" :max="999999999" :step="1" color="#747474" @change="changeValue"/> </view> </view> </view> @@ -37,72 +73,195 @@ </template> <script> - export default { - data() { - return { - matData: { - matnr: null, - maktx: null, - specs: null, - batch: null, - anfme: null, - }, - baseIP:'', - basePORT:'', - } - }, - onLoad(option) { - this.baseIP = option.baseIP - this.basePORT = option.basePORT - this.matData.matnr = option.matnr - - }, - onShow() { - this.getMat() - }, - methods: { - getMat() { - let that = this - - uni.request({ - // url: 'http://localhost:8081/jkwms/mat/auth', - url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mat/auth', - data: { - matnr: that.matData.matnr - }, - header: { - 'token':uni.getStorageSync('token') - }, - success(res) { - var res = res.data; - if (res.code === 200) { - that.matData = {} - that.matData = res.data; - } - } - }); - }, - blur() { - - }, - focus() { - - }, - changeValue() { - - }, - back() { - uni.$emit('matData', this.matData); - // console.log(this.matData) - uni.navigateBack({ - - }) - } +export default { + data() { + const now = new Date(); + const formatTime = (date) => { + return { + year: String(date.getFullYear()), + month: String(date.getMonth() + 1).padStart(2, '0'), + day: String(date.getDate()).padStart(2, '0'), + hour: String(date.getHours()).padStart(2, '0'), + minute: String(date.getMinutes()).padStart(2, '0'), + second: String(date.getSeconds()).padStart(2, '0'), + }; + }; + return { + matData: { + matnr: null, + maktx: null, + batch: null, + anfme: null, + unit: null, + proType: null, + temp2: null, + outOrderNo:null, + startTime: '', + endTime: '' + }, + commonProps: [ + '4Ni','6Ni', '8Ni', '10Ni', '闀�閾�', '鏈壊', + '闀�闀�', '鐢甸晙', '鐜懓閲�', 'PVD鎷変笣閲戝皝鍝戞补', 'PVD鎷変笣闀嶅皝鍝戞补', + '鐢垫吵浜氶粦', '姘撮晙鏋伆', '鎷変笣', '閽涢噾', '浜櫧', + '浣撴姏娌欓摐鏈壊', '鎶涘厜', '杩囩爞' + ], + selectedIndex: -1, + startTime: formatTime(now), + endTime: formatTime(now), + baseIP: '', + basePORT: '', + }; + }, + onLoad(option) { + let that = this; + + // #ifdef APP-NVUE + const eventChannel = this.$scope.eventChannel; + // #endif + // #ifndef APP-NVUE + const eventChannel = this.getOpenerEventChannel(); + // #endif + + eventChannel.on('matData', function (data) { + Object.assign(that.matData, data.data); // 淇濇寔鍝嶅簲寮� + that.matData.anfme = 1; + + if (that.matData.proType) { + that.selectedIndex = that.commonProps.indexOf(that.matData.proType); } - } + }); + }, + + methods: { + onPropChange(e) { + this.selectedIndex = e.detail.value; + this.matData.proType = this.commonProps[this.selectedIndex]; + }, + + validateNumber(field, type) { + const value = this[type][field]; + // 鍙厑璁歌緭鍏ユ暟瀛� + if (!/^\d*$/.test(value)) { + this[type][field] = value.replace(/\D/g, ''); // 鍘婚櫎闈炴暟瀛楀瓧绗� + } + + let max = 59; // 榛樿鏈�澶у�� + if (field === 'year') max = 9999; // 骞存渶澶у�间负 9999 + if (field === 'month') max = 12; // 鏈堟渶澶у�间负 12 + if (field === 'day') max = 31; // 鏃ユ渶澶у�间负 31 + if (field === 'hour') max = 23; // 灏忔椂鏈�澶у�间负 23 + if (field === 'minute' || field === 'second') max = 59; // 鍒嗛挓鍜岀鏈�澶у�间负 59 + + // 闄愬埗杈撳叆鑼冨洿 + if (parseInt(value, 10) > max) { + this[type][field] = max.toString(); // 濡傛灉瓒呭嚭鑼冨洿锛岃缃负鏈�澶у�� + } + + // 鑷姩鏇存柊瀹屾暣鏃堕棿 + this.updateFullDate(type); + }, + clearInput(field, type) { + this[type][field] = ''; // 娓呯┖鎸囧畾瀛楁鐨勫�� + }, + updateFullDate(type) { + const timeData = this[type]; + const { year, month, day, hour, minute, second } = timeData; + if ( + year.length === 4 && + month.length === 2 && + day.length === 2 && + hour.length === 2 && + minute.length === 2 && + second.length === 2 + ) { + // 鎷艰涓哄畬鏁存椂闂� + const fullDate = `${year}-${month}-${day} ${hour}:${minute}:${second}`; + // 楠岃瘉鏄惁绗﹀悎鏈夋晥鐨勬椂闂存牸寮� + if (this.isValidDate(fullDate)) { + this.matData[type === 'startTime' ? 'startTime' : 'endTime'] = fullDate; + } else { + uni.showToast({ title: '鏃堕棿鏍煎紡閿欒', icon: 'none', duration: 2000 }); + } + } + }, + + isValidDate(dateStr) { + const date = new Date(dateStr); + return date.toString() !== 'Invalid Date' && dateStr === this.formatDateTime(date); + }, + + formatDateTime(date) { + const yyyy = date.getFullYear(); + const MM = String(date.getMonth() + 1).padStart(2, '0'); + const dd = String(date.getDate()).padStart(2, '0'); + const HH = String(date.getHours()).padStart(2, '0'); + const mm = String(date.getMinutes()).padStart(2, '0'); + const ss = String(date.getSeconds()).padStart(2, '0'); + return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`; + }, + blur() { }, + focus() { }, + changeLog() { }, + changeValue(value) { + this.matData.anfme = value; + }, + back() { + if (this.matData.anfme === 0) { + uni.showToast({ title: '璇疯緭鍏ユ暟閲�', icon: 'none', position: 'top' }); + return; + } + this.getOpenerEventChannel().emit('matList', { data: this.matData }); + uni.vibrateShort(); + uni.navigateBack({}); + }, + }, +}; </script> + <style> + .attr-row { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + } + + .half-box { + width: 50%; + box-sizing: border-box; + border: 1rpx solid #ccc; + height: 60rpx; + border-radius: 8rpx; + background-color: #f9f9f9; + font-size: 24rpx; + display: flex; + align-items: center; + padding: 0 10rpx; + /* 缁熶竴瀛椾綋澶у皬锛屽乏鍙冲唴杈硅窛锛屽幓鎺変笂涓嬪唴杈硅窛纭繚鍨傜洿灞呬腑 */ + } + + .picker-box { + width: 100%; + /* 璁﹑icker鍐呭鎾戞弧鐩掑瓙 */ + height: 60rpx; + line-height: 60rpx; + /* 琛岄珮鍨傜洿灞呬腑 */ + } + + input.half-box { + border: none; + outline: none; + /* 鍘绘帀input榛樿杈规 */ + background-color: transparent; + /* 鑳屾櫙閫忔槑锛岃input鑳屾櫙璺熺埗鐩掑瓙涓�鑷� */ + font-size: 24rpx; + /* 缁ф壙瀛椾綋澶у皬 */ + height: 60rpx; + line-height: 60rpx; + /* 璁╂枃瀛楀瀭鐩村眳涓� */ + } + .container { width: 100%; height: 100%; @@ -130,8 +289,8 @@ } .text-box .text-title:last-child { display: inline-block; - margin-left: 5%; - width: 65%; + margin-left: 2%; + width: 72%; font-size: 30rpx; font-weight: 400; color: #747474; @@ -142,6 +301,28 @@ border-bottom: 1rpx solid #e8e8e8 ; width: 100%; } + .text-title input { + text-align: center; + border: 1rpx solid #e8e8e8; + border-radius: 5rpx; + padding: 5rpx; + font-size: 28rpx; + color: #747474; + } + .text-title text { + font-size: 28rpx; + color: #434343; + } + .text-title year{ + display: inline-block; + margin-left: 2%; + width: 72%; + font-size: 30rpx; + font-weight: 400; + color: #747474; + } + + .foot { @@ -154,4 +335,23 @@ border-top: 1px solid #d8d8d8; z-index: 1; } + .text-box { + display: flex; + justify-content: space-between; + align-items: center; + margin-top: 20rpx; + margin-left: 10%; + width: 80%; + border-bottom: 1rpx solid #e8e8e8; + padding-bottom: 10rpx; + } + + /* 鏍囩閮ㄥ垎鏍峰紡 */ + .label { + width: 20%; + font-size: 30rpx; + color: #434343; + } + + </style> -- Gitblit v1.9.1