1
This commit is contained in:
		| @ -107,6 +107,21 @@ | ||||
|           </el-table-column> | ||||
|           <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||||
|             <template slot-scope="scope"> | ||||
|               <el-popconfirm | ||||
|                 class="delete-popconfirm" | ||||
|                 title="确认要复制吗?" | ||||
|                 confirm-button-text="复制" | ||||
|                 @confirm="handleCopy(scope.row)" | ||||
|               > | ||||
|                 <el-button | ||||
|                   slot="reference" | ||||
|                   v-permisaction="['admin:lineOrderTemplateLogs:copy']" | ||||
|                   size="mini" | ||||
|                   type="text" | ||||
|                   icon="el-icon-document-copy" | ||||
|                 >复制 | ||||
|                 </el-button> | ||||
|               </el-popconfirm> | ||||
|               <el-popconfirm | ||||
|                 class="delete-popconfirm" | ||||
|                 title="确认要修改吗?" | ||||
| @ -678,6 +693,9 @@ export default { | ||||
|       percenter: undefined, | ||||
|       symbolGroups: [], | ||||
|       inRules: { | ||||
|         price: [{ required: true, message: '请输入下单百分比不能为空', trigger: 'blur' }, | ||||
|           { validator: this.validatePercentage, trigger: 'blur' } | ||||
|         ], | ||||
|         profit: [{ required: true, message: '请输入止盈百分比', trigger: 'blur' }, | ||||
|           { validator: this.validateProfit, trigger: 'blur' }], | ||||
|         reduce_price: [ | ||||
| @ -767,6 +785,13 @@ export default { | ||||
|     }) | ||||
|   }, | ||||
|   methods: { | ||||
|     validatePercentage(rule, value, callback) { | ||||
|       if (value <= 0 || value === undefined || value === null || value === '') { | ||||
|         callback(new Error('百分比必须大于0')) | ||||
|       } else { | ||||
|         callback() | ||||
|       } | ||||
|     }, | ||||
|     validateExtTakeProfitNumRatio(rule, value, callback) { | ||||
|       if (value === 0 || value === undefined || value === null || value === '') { | ||||
|         callback(new Error('止盈数量百分比必须大于0')) | ||||
| @ -850,9 +875,9 @@ export default { | ||||
|         callback(new Error('百分比不能小于 0')) | ||||
|       } | ||||
|  | ||||
|       if (index === 0 && item.priceRatio <= this.inForm.reduce_price) { | ||||
|       if (index === 0 && Number(item.priceRatio) <= Number(this.inForm.reduce_price)) { | ||||
|         callback(new Error('下跌百分比不能小于上一节点')) | ||||
|       } else if (index > 0 && item.priceRatio <= this.inForm.ext[index - 1].priceRatio) { | ||||
|       } else if (index > 0 && Number(item.priceRatio) <= Number(this.inForm.ext[index - 1].priceRatio)) { | ||||
|         callback(new Error('下跌百分比不能小于上一节点')) | ||||
|       } else { | ||||
|         callback() | ||||
| @ -1117,6 +1142,28 @@ export default { | ||||
|       this.single = selection.length !== 1 | ||||
|       this.multiple = !selection.length | ||||
|     }, | ||||
|     handleCopy(row) { | ||||
|       this.reset() | ||||
|       this.ext = [] | ||||
|       const id = | ||||
|         row.id || this.ids | ||||
|       getLineOrderTemplateLogs(id).then(response => { | ||||
|         this.form = response.data | ||||
|         const x = JSON.parse(response.data.params) | ||||
|         this.inForm = { ...x, api_id: x.api_id.split(','), symbol_group_id: x.symbol_group_id ? Number(x.symbol_group_id) : undefined } | ||||
|         // this.getSymbol(undefined, x.symbol_type, x.exchange_type) | ||||
|         this.onchangePattern(false) | ||||
|         this.getListLineApiUser() | ||||
|         this.form.type === 2 && this.getSymbolGroup(this.inForm.symbol_type) | ||||
|         this.form.type === 1 && this.onCalculate() | ||||
|         // 获取交易对用于计算 | ||||
|         this.getSymbol(this.inForm.symbol) | ||||
|         this.form.id = undefined | ||||
|         this.open = true | ||||
|         this.title = '添加委托下单模板' | ||||
|         this.isEdit = false | ||||
|       }) | ||||
|     }, | ||||
|     /** 修改按钮操作 */ | ||||
|     handleUpdate(row) { | ||||
|       this.reset() | ||||
| @ -1141,6 +1188,7 @@ export default { | ||||
|     }, | ||||
|     /** 提交按钮 */ | ||||
|     submitForm: function() { | ||||
|       console.log('this.form', this.form) | ||||
|       console.log('this.inForm', this.inForm) | ||||
|       Promise.all([ | ||||
|         this.$refs['inForm'].validate(), // 验证第一个表单 | ||||
| @ -1149,32 +1197,33 @@ export default { | ||||
|         .then((formValid) => { | ||||
|           if (formValid.every(valid => valid)) { | ||||
|             this.inForm.price = this.inForm.price ? String(this.inForm.price) : '' | ||||
|  | ||||
|             const params = JSON.stringify({ | ||||
|               ...this.inForm, | ||||
|               reduce_price: this.inForm.reduce_price || 0, | ||||
|               reduce_num: this.inForm.reduce_num || 0, | ||||
|               reduce_take_profit: this.inForm.reduce_take_profit || 0, | ||||
|               reduce_stop_price: this.inForm.reduce_stop_price || 0, | ||||
|               symbol_group_id: String(this.inForm.symbol_group_id), | ||||
|               profit_num_ratio: this.inForm.profit_num_ratio || 100, | ||||
|               profit_tp_tp_price_ratio: this.inForm.profit_tp_tp_price_ratio || 0, | ||||
|               profit_tp_sl_price_ratio: this.inForm.profit_tp_sl_price_ratio || 0, | ||||
|               api_id: this.inForm.api_id.toString(), | ||||
|               hedge_trigger_percent: Number(this.inForm.hedge_trigger_percent), | ||||
|               hedge_trigger_percent_max: Number(this.inForm.hedge_trigger_percent_max), | ||||
|               ext: Array.isArray(this.inForm.ext) | ||||
|                 ? this.inForm.ext.map(item => ({ | ||||
|                   ...item, | ||||
|                   stopLossRatio: item.stopLossRatio || 0, | ||||
|                   takeProfitNumRatio: item.takeProfitNumRatio || 0, | ||||
|                   tpTpPriceRatio: item.tpTpPriceRatio || 0, | ||||
|                   tpSlPriceRatio: item.tpSlPriceRatio || 0 | ||||
|                 })) | ||||
|                 : [] | ||||
|             }) | ||||
|             if (this.form.id !== undefined) { | ||||
|               this.$refs['inForm'].validate(valided => { | ||||
|                 if (!valided) return false | ||||
|                 const params = JSON.stringify({ | ||||
|                   ...this.inForm, | ||||
|                   reduce_price: this.inForm.reduce_price || 0, | ||||
|                   reduce_num: this.inForm.reduce_num || 0, | ||||
|                   reduce_take_profit: this.inForm.reduce_take_profit || 0, | ||||
|                   reduce_stop_price: this.inForm.reduce_stop_price || 0, | ||||
|                   symbol_group_id: String(this.inForm.symbol_group_id), | ||||
|                   profit_num_ratio: this.inForm.profit_num_ratio || 100, | ||||
|                   profit_tp_tp_price_ratio: this.inForm.profit_tp_tp_price_ratio || 0, | ||||
|                   profit_tp_sl_price_ratio: this.inForm.profit_tp_sl_price_ratio || 0, | ||||
|                   api_id: this.inForm.api_id.toString(), | ||||
|                   hedge_trigger_percent: Number(this.inForm.hedge_trigger_percent), | ||||
|                   hedge_trigger_percent_max: Number(this.inForm.hedge_trigger_percent_max), | ||||
|                   ext: Array.isArray(this.inForm.ext) | ||||
|                     ? this.inForm.ext.map(item => ({ | ||||
|                       ...item, | ||||
|                       stopLossRatio: item.stopLossRatio || 0, | ||||
|                       takeProfitNumRatio: item.takeProfitNumRatio || 0, | ||||
|                       tpTpPriceRatio: item.tpTpPriceRatio || 0, | ||||
|                       tpSlPriceRatio: item.tpSlPriceRatio || 0 | ||||
|                     })) | ||||
|                     : [] | ||||
|                 }) | ||||
|  | ||||
|                 updateLineOrderTemplateLogs({ ...this.form, params }).then(response => { | ||||
|                   if (response.code === 200) { | ||||
| @ -1187,7 +1236,7 @@ export default { | ||||
|                 }) | ||||
|               }) | ||||
|             } else { | ||||
|               addLineOrderTemplateLogs({ ...this.inForm, symbol_group_id: String(this.inForm.symbol_group_id), api_id: this.inForm.api_id.toString() }).then(response => { | ||||
|               addLineOrderTemplateLogs({ ...this.form, params }).then(response => { | ||||
|                 if (response.code === 200) { | ||||
|                   this.msgSuccess(response.msg) | ||||
|                   this.open = false | ||||
|  | ||||
| @ -1368,6 +1368,9 @@ export default { | ||||
|       }, | ||||
|       // 表单校验 | ||||
|       rules: { | ||||
|         price: [{ required: true, message: '请输入下单百分比不能为空', trigger: 'blur' }, | ||||
|           { validator: this.validatePercentage, trigger: 'blur' } | ||||
|         ], | ||||
|         profit: [{ required: true, message: '请输入止盈百分比', trigger: 'blur' }, { validator: this.validateProfit, trigger: 'blur' }], | ||||
|         reduce_price: [ | ||||
|           { required: true, message: '主单亏损减仓百分比不能为空', trigger: 'blur' }, | ||||
| @ -1984,6 +1987,13 @@ export default { | ||||
|       } | ||||
|       this.resetForm('form') | ||||
|     }, | ||||
|     validatePercentage(rule, value, callback) { | ||||
|       if (value <= 0 || value === undefined || value === null || value === '') { | ||||
|         callback(new Error('百分比必须大于0')) | ||||
|       } else { | ||||
|         callback() | ||||
|       } | ||||
|     }, | ||||
|     validateExtTakeProfitNumRatio(rule, value, callback) { | ||||
|       if (value === 0 || value === undefined || value === null || value === '') { | ||||
|         callback(new Error('止盈数量百分比必须大于0')) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user