我有2个仪表板,一个用于用户(printshop),另一个用于管理员(QA),我希望当管理员更改管理仪表盘中的订单状态而无需刷新时自动更新用户仪表盘每次发生更改时的页面。
这里 质量检查信息中心中的myService.js
function addOrederToPrintShop(printShopId, orderId, index, key) {
return new Promise(function(resolve, reject) {
service.db.collection('orders').doc(orderId).set({
printShopStatus: 'Pending'
}, {
merge: true
}).then(function(data) {
service.db.collection('print-shops-
orders ').doc(printShopId).collection(orderId).doc(key).get()
.then(function(doc) {
if (!doc.exists) {
////if print shop not added
service.db.collection('print-shops-
orders ').doc(printShopId).collection(orderId).doc(key).set({key:
key
})
.then(function() {
addOredersToPrintShopArray(printShopId, orderId);
service.db.collection('orders').doc(orderId).get()
.then(function(order) {
if (order.exists) {
var fetchedOrder = order.data();
fetchedOrder.cart[index].printShopStatus = 'Pending';
service.db.collection('orders').doc(orderId).set({
cart: fetchedOrder.cart
}, {
merge: true
}).then(function() {
resolve('Document successfully added!');
});
}
});
})
.catch(function(error) {
reject("Error added document: ", error);
});
} else {
resolve('Document NOT!');
}
});
});
});
}