Files
zszq-trs/YLErpWeb/wwwroot/Scripts/app/swapRate/swapFloatRateEdit.js
T
2025-04-23 10:31:04 +08:00

162 lines
6.8 KiB
JavaScript

//otcformat禁止千分位分组
window.otcformat.options.disableGrouping = true;
const inputFormatInteger = Object.freeze({ precision: 0, append: '' });
const inputFormatRate = Object.freeze({ precision: otcformat.trading.premiumRateP.precision, negative: true, append: '%' });
const inputFormatSinglePrice = Object.freeze({ precision: otcformat.trading.umprice.precision, negative: true, append: '' });
//标的选择组件
const vueUnderlying = function () {
return {
props: ['value', 'index'],
data() {
return { autoUnderlying: null };
},
mounted() {
var selFlag = tradeHelper.UnderlyingSelectFlag;
this.autoUnderlying = tradeHelper.UnderlyingAutoComplete(this.$el, { SelectFlag: selFlag.UsePinYinFilter | selFlag.UseForTrading | selFlag.IncludeSynthetic | selFlag.IncludeMatured | selFlag.IncludeBasket | selFlag.CheckLaunch, BlackLimit: 2, UseAll: true, UseSignle: true });
this.autoUnderlying.onSelect(this.onchange);
this.value && this.autoUnderlying.selectByCode(this.value);
},
methods: {
onchange(data) {
this.$emit('change', data);
this.$emit('input', data.Code);
}
},
destroyed() {
this.autoUnderlying && this.autoUnderlying.dispose();
},
template: '<input type="text" v-model="value" />'
};
};
//标的选择组件 银行间回购定盘&其他利率
const vueUnderlyingRate = function () {
return {
props: ['value', 'index'],
data() {
return { autoUnderlying: null };
},
mounted() {
var selFlag = tradeHelper.UnderlyingSelectFlag;
var instrumentTypes = ["FixingRepoRate", "OtherRate"];
this.autoUnderlying = tradeHelper.UnderlyingAutoComplete(this.$el, { SelectFlag: selFlag.UsePinYinFilter | selFlag.UseForTrading | selFlag.IncludeSynthetic | selFlag.IncludeMatured | selFlag.IncludeBasket | selFlag.CheckLaunch, BlackLimit: 2, InstrumentTypes: instrumentTypes, UseAll: true, UseSignle: true });
this.autoUnderlying.onSelect(this.onchange);
this.value && this.autoUnderlying.selectByCode(this.value);
},
methods: {
onchange(data) {
data.index = this.index;
if (this.value !== data.Code) {
this.$emit('change', data);
this.$emit('input', data.Code);
}
}
},
destroyed() {
this.autoUnderlying && this.autoUnderlying.dispose();
},
template: '<input type="text" v-model="value" />'
};
};
var vue = new Vue({
el: "#rateEditModal",
data: {
rate: {
id: 0,
RateMode: 0,
UnderlyingCode: "",
StartDate: null,
EndDate: null,
BaseUnderlyingCode:"",
LongPricePoint: null,
ShortPricePoint: null,
is_annualized: null,
interest_type: null,
interest_rest_days: null,
interest_rule: null,
}
},
mounted: function () {
this.rate = model;
let thisObbj = this;
if (this.rate.RateMode==1) {
let autoClient = FastVue.autocomplete(document.getElementById('ClientId'), {
nameField: 'Name', valueField: 'id', searchField: ['Name', 'PinYin'],
lookup: clients, onSelect: function (rep) {
thisObbj.changeClient(rep);
}
});
let clientId = model.ClientId;
let client = clientId >= 0 ? clients.find(x => x.id === clientId) : null;
autoClient.setData(client);
}
this.rate.UnderlyingCode = this.rate.UnderlyingCode == null ? "--" : this.rate.UnderlyingCode;
this.rate.BaseUnderlyingCode = this.rate.BaseUnderlyingCode == null ? "--" : this.rate.BaseUnderlyingCode;
if (this.rate.StartDate!=null) {
this.rate.StartDate = moment(this.rate.StartDate).format('YYYY-MM-DD');
}
if (this.rate.EndDate != null) {
this.rate.EndDate = moment(this.rate.EndDate).format('YYYY-MM-DD');
}
},
methods: {
save() {
var thisObj = this;
thisObj.rate.UnderlyingCode = thisObj.rate.UnderlyingCode == "--" ? null : thisObj.rate.UnderlyingCode;
thisObj.rate.BaseUnderlyingCode = thisObj.rate.BaseUnderlyingCode == "--" ? null : thisObj.rate.BaseUnderlyingCode;
if (thisObj.rate.RateMode==1) {
if (thisObj.rate.ClientId == null || thisObj.rate.ClientId.length == 0) {
return main.alert("请选择客户名称");
}
}
if (thisObj.rate.StartDate == null || thisObj.rate.StartDate.length == 0) {
return main.alert("请选择生效起始日");
}
if (thisObj.rate.EndDate == null || thisObj.rate.EndDate.length == 0) {
return main.alert("请选择生效终止日");
}
if (thisObj.rate.interest_rest_days == null) {
return main.alert("请填写重置频率");
}
if (thisObj.rate.interest_rest_days < 1 && thisObj.rate.BaseUnderlyingCode != null) {
return main.alert("重置频率必须大于0");
}
if (thisObj.rate.EndDate < thisObj.rate.StartDate) {
return main.alert("生效终止日不能早于生效起始日");
}
if (thisObj.rate.LongPricePoint == null && thisObj.rate.ShortPricePoint == null) {
return main.alert("多头价格加点、空头价格减点必须填写一个");
}
main.post("/SwapFloatRate/SaveSwapFloatRate", { req: thisObj.rate }).done(function (resp) {
if (resp.success) {
thisObj.close();
} else {
main.alert(resp.msg);
}
})
},
changeUnderlyingCode(data) {
this.rate.UnderlyingCode = data.Code;
},
changeClient: function (client) {
this.rate.ClientId = client.id;
this.rate.ClientNumber = client.Number;
},
setFloatRateUnderlyingCode(data) {
this.rate.BaseUnderlyingCode = data.Code;
if (data.Code.length > 0 && data.Code != '--') {
this.rate.is_annualized = true;
}
},
close() {
window.parent.reloadData();
layer.closeMe();
}
},
components: {
'vue-datepicker': FastVue.vueDatePicker(),
'vue-number-input': FastVue.vueNumberInput(),
'vue-underlying': vueUnderlying(),
'vue-underlying-rate': vueUnderlyingRate()
},
});