From 3973e76d94412dd26d525daa15af23aa6a5f3225 Mon Sep 17 00:00:00 2001
From: 快乐的昕的电脑 <快乐的昕的电脑@DESKTOP-C2BQPQU>
Date: 星期五, 14 十一月 2025 09:39:17 +0800
Subject: [PATCH] 回调
---
components/machine.vue | 361 ++++++++++++++++++++++++++++++++-------------------
1 files changed, 228 insertions(+), 133 deletions(-)
diff --git a/components/machine.vue b/components/machine.vue
index 90c6533..cf6a77e 100644
--- a/components/machine.vue
+++ b/components/machine.vue
@@ -157,40 +157,63 @@
},
// 淇濆瓨骞剁敓鏁堬紝灏嗘椂闂寸瓑淇℃伅鎻愪氦鍒板悗绔�
// 鍙樻洿锛氳繑鍥� Promise锛涙垚鍔熷悗灞�閮ㄥ埛鏂帮紙璋冪敤 findByOrderId锛夎�屼笉鏄暣椤� reload
- save() {
- if (!this.statusForm.id) {
- this.$showMessage("id涓虹┖锛屼笉鍏佽鎺ㄩ��");
- return Promise.resolve();
- }
- return this.$post({
- url: "/MesOrderSta/ChangeMachineTime",
- data: {
- maStartTime: this.maStartTime,
- maShoutTime: this.maShoutTime,
- maEndTime: this.maEndTime,
- id: this.statusForm.id,
- orderId: this.orderId,
- machineNo: this.machineNo,
- flag: this.flag
- }
- }).then(res => {
- if (res && res.data && res.data.tbBillList) {
- this.$showMessage("鍛煎彨鎴愬姛");
- // 灞�閮ㄥ埛鏂帮細閲嶆柊鎷夊彇褰撳墠宸ュ崟鐘舵�佸苟鏇存柊褰撳墠缁勪欢鏁版嵁
- this.findByOrderId();
- // 濡傛灉闇�瑕佸湪淇濆瓨鍚庡叧闂璇濇鎴栬繑鍥炰笂涓�绾э紝鍙湪杩欓噷澶勭悊
- } else {
- this.$showMessage("鍛煎彨澶辫触");
- this.cancel();
- }
- return res;
- }).catch(err => {
- // 淇濇寔鍙嬪ソ鐨勯敊璇彁绀哄苟灏嗛敊璇姏鍑轰互渚垮閮ㄩ摼寮忓鐞�
- console.error('淇濆瓨澶辫触锛�', err);
- this.$showMessage("淇濆瓨鏃跺彂鐢熼敊璇�");
- throw err;
- });
- },
+ save() {
+ if (!this.statusForm.id) {
+ this.$showMessage("id涓虹┖锛屼笉鍏佽鎺ㄩ��");
+ return Promise.resolve();
+ }
+ return this.$post({
+ url: "/MesOrderSta/ChangeMachineTime",
+ data: {
+ maStartTime: this.maStartTime,
+ maShoutTime: this.maShoutTime,
+ maEndTime: this.maEndTime,
+ id: this.statusForm.id,
+ orderId: this.orderId,
+ machineNo: this.machineNo,
+ flag: this.flag
+ }
+ }).then(res => {
+ if (res && res.data && res.data.tbBillList) {
+ this.$showMessage("鍛煎彨鎴愬姛");
+
+ // 鍏抽敭淇敼锛氭竻绌� flag 鐨勫��
+ this.flag = -1; // 鎴栬�呮牴鎹笟鍔¢渶姹傝缃负鍏朵粬鍒濆鍊�
+
+ // 鏂规1锛氫娇鐢╱ni-app鐨勯〉闈㈠埛鏂版柟娉�
+ // 鏂规硶1锛氳Е鍙戜笅鎷夊埛鏂帮紙濡傛灉椤甸潰鏀寔锛�
+ if (uni.startPullDownRefresh) {
+ uni.startPullDownRefresh();
+ // 2绉掑悗鍋滄鍒锋柊
+ setTimeout(() => {
+ uni.stopPullDownRefresh();
+ }, 2000);
+ }
+
+ // 鏂规硶2锛氶噸鏂拌皟鐢ㄩ〉闈㈢殑onLoad鏂规硶锛堟帹鑽愶級
+ const pages = getCurrentPages();
+ const currentPage = pages[pages.length - 1];
+ if (currentPage && currentPage.onLoad) {
+ // 淇濆瓨褰撳墠椤甸潰鍙傛暟
+ const pageOptions = currentPage.options || {};
+ // 閲嶆柊鍔犺浇椤甸潰鏁版嵁
+ currentPage.onLoad(pageOptions);
+ }
+
+ // 鏂规硶3锛氬悓鏃跺埛鏂扮粍浠舵暟鎹�
+ this.findByOrderId();
+
+ } else {
+ this.$showMessage("鍛煎彨澶辫触");
+ this.cancel();
+ }
+ return res;
+ }).catch(err => {
+ console.error('淇濆瓨澶辫触锛�', err);
+ this.$showMessage("淇濆瓨鏃跺彂鐢熼敊璇�");
+ throw err;
+ });
+ },
// 鍙栨秷鎿嶄綔锛屾仮澶嶄负涓婃淇濆瓨鐨勬暟鎹�
cancel() {
this.maShoutTime = this.statusForm.maShoutTime;
@@ -234,12 +257,20 @@
})
}
},
- mounted() {
- // 椤甸潰鍔犺浇鏃讹紝鍚姩瀹氭椂鍣紝姣忛殧5鍒嗛挓鑷姩淇濆瓨锛堝綋鍓嶇ず渚嬩娇鐢� 30s锛屽彲鏀瑰洖 5 鍒嗛挓锛�
- this.autoSaveTimer = setInterval(() => {
- this.save(); // 鐩存帴璋冪敤宸叉湁鐨勪繚瀛樻柟娉曪紙save 宸茶繑鍥� Promise锛�
- }, 1 * 30 * 1000); // 30绉�
- },
+ mounted() {
+ // 椤甸潰鍔犺浇鏃讹紝鍚姩瀹氭椂鍣紝姣忛殧30绉掕嚜鍔ㄤ繚瀛�
+ this.autoSaveTimer = setInterval(() => {
+ // 1. 璋冩満瀹屾垚鏃堕棿鏈変簡灏变笉鑷姩淇濆瓨
+ if (this.maEndTime) {
+ return;
+ }
+ // 2. 閫佹鏃堕棿涓虹┖涔熶笉鑷姩淇濆瓨
+ if (!this.maShoutTime) {
+ return;
+ }
+ this.save(); // 婊¤冻鏉′欢鎵嶈嚜鍔ㄤ繚瀛�
+ }, 1 * 30 * 1000); // 30绉�
+ },
beforeDestroy() {
// 椤甸潰鍗歌浇鏃舵竻鐞嗗畾鏃跺櫒
clearInterval(this.autoSaveTimer);
@@ -248,110 +279,174 @@
</script>
<style scoped>
- /* 椤甸潰鏁翠綋甯冨眬 */
- .page {
- padding: 2vh;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- box-sizing: border-box;
- height: 100%;
- }
+ /* 椤甸潰鏁翠綋甯冨眬 */
+ .page {
+ padding: 8px;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ box-sizing: border-box;
+ height: 100%;
+ }
- /* 鍙充笂瑙掑埛鏂版寜閽� */
- .top-right {
- position: absolute;
- top: 10px;
- right: 50px;
- z-index: 1000;
- }
+ /* 鍙充笂瑙掑埛鏂版寜閽� */
+ .top-right {
+ position: absolute;
+ top: 8px;
+ right: 40px;
+ width: 200px;
+ z-index: 1000;
+ }
- .refresh-btn {
- padding: 10px;
- background-color: #00A2E9;
- color: white;
- border: none;
- font-size: 1.5vw;
- border-radius: 5px;
- }
+ .refresh-btn {
+ padding: 8px 16px;
+ background-color: #00A2E9;
+ color: white;
+ border: none;
+ font-size: 22px;
+ border-radius: 5px;
+ }
- label {
- margin-right: 1vw;
- font-size: 1.6vw;
- }
+ label {
+ margin-right: 10px;
+ font-size: 22px;
+ }
- input {
- padding: 1vh;
- font-size: 1.5vw;
- border: 1px solid #ccc;
- width: 100%;
- margin-top: 1vh;
- box-sizing: border-box;
- }
+ /* 涓棿鐘舵�侀儴鍒嗗竷灞� */
+ .middle-section {
+ display: flex;
+ flex-direction: column;
+ margin-bottom: 8px;
+ }
- /* 涓棿鐘舵�侀儴鍒嗗竷灞� */
- .middle-section {
- display: flex;
- flex-direction: column;
- margin-bottom: 4vh;
- }
+ .item {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ margin-bottom: 10px;
+ gap: 10px;
+ }
- .item {
- display: flex;
- flex-direction: row;
- align-items: flex-start;
- margin-bottom: 2vh;
- }
+ .item h4 {
+ font-size: 18px;
+ line-height: 1.4;
+ margin: 0;
+ padding: 5px 0;
+ }
- button {
- width: 100%;
- padding: 1.5vh;
- font-size: 1.5vw;
- border: none;
- text-align: center;
- }
+ button {
+ width: 50%;
+ flex-shrink: 0;
+ padding: 10px;
+ font-size: 22px;
+ border: none;
+ text-align: center;
+ min-height: 40px;
+ }
- .btn-disabled {
- background-color: #ccc;
- color: white;
- }
+ .btn-disabled {
+ background-color: #ccc;
+ color: white;
+ }
- .btn-blue {
- background-color: #00A2E9;
- color: white;
- }
+ .btn-blue {
+ background-color: #00A2E9;
+ color: white;
+ }
- input {
- margin-top: 10px;
- padding: 10px;
- font-size: 14px;
- border: 1px solid #ccc;
- width: 100%;
- }
+ input {
+ margin-top: 0;
+ padding: 8px;
+ font-size: 24px;
+ border: 1px solid #ccc;
+ width: 50%;
+ flex-grow: 1;
+ box-sizing: border-box;
+ }
- /* 搴曢儴淇濆瓨/鍙栨秷鎸夐挳甯冨眬 */
- .bottom-section {
- display: flex;
- justify-content: space-between;
- margin-top: 4vh;
- }
+ /* 搴曢儴淇濆瓨/鍙栨秷鎸夐挳甯冨眬 */
+ .bottom-section {
+ display: flex;
+ justify-content: space-between;
+ margin-top: 10px;
+ padding-top: 10px;
+ }
- .save-btn,
- .cancel-btn {
- width: 48%;
- padding: 1.5vh;
- background-color: #00A2E9;
- color: white;
- font-size: 1.6vw;
- border: none;
- text-align: center;
- }
+ .save-btn,
+ .cancel-btn {
+ width: 48%;
+ padding: 12px;
+ background-color: #00A2E9;
+ color: white;
+ font-size: 24px;
+ border: none;
+ text-align: center;
+ min-height: 45px;
+ }
- .txt-inp {
- height: 8vh;
- padding: 1vh;
- font-size: 1.5vw;
- width: 100%;
- box-sizing: border-box;
- }
+ .txt-inp {
+ height: 70px; /* 澧炲ぇ楂樺害 */
+ padding: 12px; /* 澧炲ぇ鍐呰竟璺� */
+ font-size: 24px; /* 澧炲ぇ瀛椾綋 */
+ width: 50%;
+ flex-grow: 1;
+ box-sizing: border-box;
+ margin-top: 0;
+ }
+
+ /* 閽堝1280*717灞忓箷鐨勭壒瀹氫紭鍖� */
+ @media screen and (max-width: 1280px) and (max-height: 800px) {
+ .page {
+ padding: 6px;
+ }
+
+ .middle-section {
+ margin-bottom: 6px;
+ }
+
+ .item {
+ margin-bottom: 8px;
+ }
+
+ .item h4 {
+ font-size: 16px;
+ padding: 3px 0;
+ }
+
+ button {
+ padding: 8px;
+ font-size: 20px;
+ min-height: 38px;
+ }
+
+ .txt-inp {
+ height: 46px;
+ padding: 10px;
+ font-size: 22px;
+ }
+
+ .bottom-section {
+ margin-top: 8px;
+ padding-top: 8px;
+ }
+
+ .save-btn,
+ .cancel-btn {
+ padding: 10px;
+ font-size: 22px;
+ min-height: 42px;
+ }
+
+ input {
+ font-size: 22px;
+ }
+
+ .refresh-btn {
+ font-size: 20px;
+ }
+
+ label {
+ font-size: 20px;
+ }
+ }
</style>
\ No newline at end of file
--
Gitblit v1.9.3