增加一個新的報名牌位編輯功能
This commit is contained in:
+108
-1
@@ -464,6 +464,11 @@
|
||||
initialized: false,
|
||||
currentItem: {}
|
||||
},
|
||||
tablet_edit_new: {
|
||||
show: false,
|
||||
initialized: false,
|
||||
currentItem: {}
|
||||
},
|
||||
//收款註記
|
||||
cash_dialog: {
|
||||
show: false,
|
||||
@@ -547,6 +552,7 @@
|
||||
|
||||
// 關閉編輯對話框
|
||||
this.tablet_edit.show = false;
|
||||
thiw.tablet_edit_new.show = false;
|
||||
|
||||
// 顯示成功訊息
|
||||
this.snackbar.text = '牌位資料已更新';
|
||||
@@ -561,6 +567,13 @@
|
||||
this.tablet_edit.initialized = true;
|
||||
};
|
||||
}
|
||||
|
||||
const iframe1 = document.querySelector('iframe#tablet_edit_new_iframe');
|
||||
if (iframe1) {
|
||||
iframe1.onload = () => {
|
||||
this.tablet_edit_new.initialized = true;
|
||||
};
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
options: {
|
||||
@@ -577,6 +590,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
'tablet_edit_new.show': {
|
||||
handler(newVal) {
|
||||
if (!newVal && this._savedEditedItem) {
|
||||
this.editedItem = $.extend(true, {}, this._savedEditedItem);
|
||||
this._savedEditedItem = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
optionsDetail: {
|
||||
handler() {
|
||||
this.initialize();
|
||||
@@ -819,6 +840,32 @@
|
||||
this.editedItem = $.extend(true, {}, item);
|
||||
this.file_dialog.show = true;
|
||||
},
|
||||
async editTabletNew(item) {
|
||||
this.editedIndex = this.desserts.indexOf(item);
|
||||
this.editedItem = $.extend(true, {}, item);
|
||||
|
||||
try {
|
||||
// 如果是新項目,先保存
|
||||
if (this.editedItem.num <= 0 || this.editedItem.num === null || this.editedItem.num === undefined) {
|
||||
this.editedItem.qty = 1;
|
||||
const savedItem = await this.save(false);
|
||||
if (savedItem) {
|
||||
this.$set(this.desserts, this.editedIndex, savedItem);
|
||||
this.editedItem = $.extend(true, {}, savedItem);
|
||||
}
|
||||
}
|
||||
// 先發送消息
|
||||
await this.sendMessageToIframeNew();
|
||||
// 保存當前的 editedItem 數據
|
||||
const currentData = $.extend(true, {}, this.editedItem);
|
||||
// 顯示對話框
|
||||
this.tablet_edit_new.show = true;
|
||||
// 立即恢復數據
|
||||
this.editedItem = $.extend(true, {}, currentData);
|
||||
} catch (error) {
|
||||
console.error('Error in editTablet:', error);
|
||||
}
|
||||
},
|
||||
async editTablet(item) {
|
||||
this.editedIndex = this.desserts.indexOf(item);
|
||||
this.editedItem = $.extend(true, {}, item);
|
||||
@@ -845,6 +892,52 @@
|
||||
console.error('Error in editTablet:', error);
|
||||
}
|
||||
},
|
||||
async sendMessageToIframeNew() {
|
||||
const iframe = document.querySelector('iframe#tablet_edit_new_iframe');
|
||||
|
||||
// 在這裡深度複製 editedItem,確保數據不會被修改
|
||||
const itemToSend = $.extend(true, {}, this.editedItem);
|
||||
|
||||
if (iframe) {
|
||||
try {
|
||||
// 準備要發送的數據
|
||||
let familyMembers = [];
|
||||
|
||||
try {
|
||||
// 嘗試獲取家族成員數據
|
||||
const response = await axios.get(HTTP_HOST + 'api/familymembers/follower/' + this.follower_id);
|
||||
familyMembers = response.data;
|
||||
} catch (error) {
|
||||
console.warn('error:', error);
|
||||
}
|
||||
|
||||
// 準備發送的數據
|
||||
const itemInfo = {
|
||||
source: 'order.btn.click',
|
||||
tabletItem: {
|
||||
...itemToSend,
|
||||
title: this.titleword() // 確保標題被包含
|
||||
},
|
||||
familyMembers: familyMembers
|
||||
};
|
||||
|
||||
iframe.contentWindow.postMessage(itemInfo, '*');
|
||||
|
||||
// 發送後確認數據完整性
|
||||
|
||||
// 如果數據被清除,立即恢復
|
||||
if (!this.editedItem.num && itemToSend.num) {
|
||||
this.$nextTick(() => {
|
||||
this.editedItem = $.extend(true, {}, itemToSend);
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error in sendMessageToIframe:', error);
|
||||
}
|
||||
} else {
|
||||
console.error('iframe not found');
|
||||
}
|
||||
},
|
||||
async sendMessageToIframe() {
|
||||
const iframe = document.querySelector('iframe#tablet_edit_iframe');
|
||||
|
||||
@@ -2001,7 +2094,10 @@
|
||||
</v-icon>
|
||||
<v-icon title="編輯牌位" color="blue" class="mr-2" @click="editTablet(item);">
|
||||
mdi-file-document-edit-outline
|
||||
</v-icon>
|
||||
</v-icon>
|
||||
<v-icon title="編輯牌位New" color="blue" class="mr-2" @click="editTabletNew(item);">
|
||||
mdi-file-document-edit-outline
|
||||
</v-icon>
|
||||
<v-icon title="列印" color="blue" class="mr-2" @click="printItem(item);" v-if="canPrint || lists.length==0" >
|
||||
mdi-printer
|
||||
</v-icon>
|
||||
@@ -2569,6 +2665,17 @@
|
||||
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<v-dialog v-model="tablet_edit_new.show" min-width="100vw" min-height="100vh" persistent eager :class="{'d-none': !tablet_edit_new.initialized}">
|
||||
<v-card>
|
||||
<v-card-title class="justify-space-between grey lighten-2">
|
||||
<span class="fs-6 text text-dark">編輯牌位 : {{editedItem.actitem_num_selected.text}} - {{editedItem.print_id}}</span>
|
||||
<v-btn icon @click="tablet_edit_new.show=false"><v-icon>mdi-close</v-icon></v-btn>
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<iframe id="tablet_edit_new_iframe" src="../print/tablet_edit/editorNewOne.html" style="width: 100%; height: 100%;min-height:100vh;min-width:100vw" frameborder="0"></iframe>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<v-dialog v-model="tablet_edit.show" max-width="1000px" persistent eager :class="{'d-none': !tablet_edit.initialized}">
|
||||
<v-card>
|
||||
<v-card-title class="justify-space-between grey lighten-2">
|
||||
|
||||
Reference in New Issue
Block a user