|
@@ -118,12 +118,18 @@
|
|
|
},
|
|
|
watch: {
|
|
|
restrictOrder: {
|
|
|
- handler(newOrder) {
|
|
|
- console.log('this.stop_loss_price restrictOrder ' , newOrder)
|
|
|
+ handler(newOrder, oldOrder) {
|
|
|
if (newOrder) {
|
|
|
this.calculateProfitPrice(this.target_profit_price)
|
|
|
this.calculateLossPrice(this.stop_loss_price)
|
|
|
}
|
|
|
+ if (!oldOrder || (newOrder && newOrder.stop_loss_price !== oldOrder.stop_loss_price)) {
|
|
|
+ console.log('this.stop_loss_price restrictOrder ' ,1)
|
|
|
+ this.stop_loss_price = newOrder?.stop_loss_price || '';
|
|
|
+ }
|
|
|
+ if (!oldOrder || (newOrder && newOrder.target_profit_price !== oldOrder.target_profit_price)) {
|
|
|
+ this.target_profit_price = newOrder?.target_profit_price || '';
|
|
|
+ }
|
|
|
},
|
|
|
immediate: true,
|
|
|
deep: true
|
|
@@ -153,27 +159,36 @@
|
|
|
},
|
|
|
methods: {
|
|
|
calculateProfitPrice(newPrice) {
|
|
|
- if (newPrice && this.restrictOrder && newPrice > Number(this.restrictOrder
|
|
|
- .update_price)) {
|
|
|
- this.profitPrice = ((newPrice - this.restrictOrder.update_price) * 100 / this
|
|
|
- .restrictOrder.update_price * this.restrictOrder.caution_money).toFixed(2);
|
|
|
- } else {
|
|
|
+ // if (newPrice && this.restrictOrder && newPrice > Number(this.restrictOrder.update_price)) {
|
|
|
+ try {
|
|
|
+ if (newPrice && this.restrictOrder) {
|
|
|
+ this.profitPrice = ((newPrice - this.restrictOrder.update_price) * 100 / this
|
|
|
+ .restrictOrder.update_price * this.restrictOrder.caution_money).toFixed(2);
|
|
|
+ } else {
|
|
|
+ this.profitPrice = ''
|
|
|
+ }
|
|
|
+ } catch {
|
|
|
this.profitPrice = ''
|
|
|
}
|
|
|
},
|
|
|
|
|
|
calculateLossPrice(newPrice) {
|
|
|
- if (newPrice && this.restrictOrder && newPrice < Number(this.restrictOrder.update_price)) {
|
|
|
- // console.log('this.calculateLossPrice = ' , newPrice , this.restrictOrder.update_price)
|
|
|
- this.lossPrice = ((newPrice - this.restrictOrder.update_price) * 100 / this
|
|
|
- .restrictOrder.update_price * this.restrictOrder.caution_money).toFixed(2);
|
|
|
- } else {
|
|
|
+ // if (newPrice && this.restrictOrder && newPrice < Number(this.restrictOrder.update_price)) {
|
|
|
+ try {
|
|
|
+ if (newPrice && this.restrictOrder) {
|
|
|
+ // console.log('this.calculateLossPrice = ' , newPrice , this.restrictOrder.update_price)
|
|
|
+ this.lossPrice = ((newPrice - this.restrictOrder.update_price) * 100 / this
|
|
|
+ .restrictOrder.update_price * this.restrictOrder.caution_money).toFixed(2);
|
|
|
+ } else {
|
|
|
+ this.lossPrice = ''
|
|
|
+ }
|
|
|
+ } catch {
|
|
|
this.lossPrice = ''
|
|
|
}
|
|
|
+
|
|
|
},
|
|
|
open(item = null) {
|
|
|
- this.target_profit_price = '';
|
|
|
- this.stop_loss_price = '';
|
|
|
+
|
|
|
// this.content = item;
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.popupRef.open();
|
|
@@ -181,6 +196,8 @@
|
|
|
},
|
|
|
close() {
|
|
|
this.$refs.popupRef.close()
|
|
|
+ this.target_profit_price = '';
|
|
|
+ this.stop_loss_price = '';
|
|
|
},
|
|
|
change(e) {
|
|
|
if (!e.show) {
|